CodeIgniter Forums
echo array of inputs - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: echo array of inputs (/showthread.php?tid=59025)



echo array of inputs - El Forum - 08-15-2013

[eluser]CocoMansur[/eluser]
Hi,

this is my code in HTML

Code:
<?php foreach($query2->result() as $row): ?>
<input type="hidden" name="outlays_id[]" value="<?php echo $row->id; ?>" />
<?php endforeach; ?>

i would like to display the values first using for loop

Code:
for($x=0; $x<count($this->input->post('outlays_id')); $x++)
echo $this->input->post("outlays_id[$x]");

the above code doesn't display anything...

but using foreach it displays the value of each array...

how can i make it display using for loop?

using CI 2.1.4


echo array of inputs - El Forum - 08-15-2013

[eluser]CocoMansur[/eluser]
Got it...

here is my code to display it with for loop

Code:
$test = $this->input->post('outlays_id');
for($x=0; $x<count($test); $x++){
   echo $test[$x];
}

anyway, is there a way to not pass it to a variable?