0

I'm new in codeigniter framework, I just want to get the values from selected dropdown array in my form using CI. Assumed these are the whole process.

I have form with auto populated cities,

example in view

<select name="city[]">
<option value="ABC"> ABC </option>
</select>

<select name="city[]">
<option value="EFG"> EFG </option>
</select>

Here is the controller

$this->form_validation->set_rules('city[]', 'city');

When I echo it out on my model form

echo $this->input->post('city');

it just shows array, Any ideas?

1
  • Because it is an array and contains multiple values. And because you can't echo an array. Use print_r() or var_dump() to see what's inside and access a specific value if you'd like or loop through the array if you want all of them. Commented Apr 24, 2014 at 16:10

2 Answers 2

0

This is because is an array :D.

When you echo a variable of type array it shows "Array", do a print_r instead

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

Comments

0

Your view should look like -

<select name="city[]" multiple="multiple">
  <option value="ABC"> ABC </option>
  <option value="EFG"> EFG </option>
</select>


PHP:

echo '<pre>'; print_r($this->input->post('city'));

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.