0

I am learning a CI, I got a tutorial,Its a little old, In that trutorial it shows working without any issue, but I am getting a notice like this :: A PHP Error was encountered Severity: Notice Message: Array to string conversion

Here is the code::

$rules = array(
    'name'=>array(
        'field'=>'name', 
        'label'=>'Name', 
        'rules'=>'trim|required'
    ),
    'email'=>array(
        'field'=>'email', 
        'label'=>'Email', 
        'rules'=>'trim|required|valid_email|callback__unique_email'
    ),
    'password'=>array(
        'field'=>'password', 
        'label'=>'Password', 
        'rules'=>'trim|matches[password_confirm]'
    )
)

To add a required rule to password filed, it was used like this

$rules['password'] .= '|required';

But when I use this, not working, when I var dump, I am getting this

'password' => string 'Array|required' (length=14)

I am using PHP 5.6, Is there any thing wrong with the code, any help will be appreciated. thank you

Expected value will be like this

    array (size=4)
  'name' => 
    array (size=3)
      'field' => string 'name' (length=4)
      'label' => string 'Name' (length=4)
      'rules' => string 'trim|required' (length=13)
  'email' => 
    array (size=3)
      'field' => string 'email' (length=5)
      'label' => string 'Email' (length=5)
      'rules' => string 'trim|required|valid_email|callback__unique_email' (length=48)
  'password' => 
    array (size = 3)
    'field' => string 'password' (length=16)
        'label' => string 'Password' (length=16)
        'rules' => string 'trim|matches[confirm_password]|required' (length=22) 
2
  • 2
    $rules['password']['rules'] .= '|required'; Commented Nov 27, 2016 at 16:06
  • thats it, thank you Commented Nov 27, 2016 at 16:11

1 Answer 1

1

I think you need right index specification: $rules['password']['rules'] .= '|required';

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.