Welcome Guest, Not a member yet? Register   Sign In
how to retrieve the values of mulple list?
#7

[eluser]xwero[/eluser]
This is what i do when i need to handle several equal length arrays
Code:
$community = $this->input->post('community');
$location = $this->input->post('location');
$membercount = $this->input->post('membercount');
$i = 0;
foreach($community as $user){
//do something with user
//do something with location[$i]
//do something with membercount[$i]
$i++;
}
When you use a foreach you can split the item up in key and value so you can work with associate arrays too.

btw using the count function every time the loop restarts isn't good for performance. This is better:
Code:
for($i=0, $max = count($community); $i<=$max;$i++){

Foreach is not absolute performance but i think flexibility is a big issue too. But of course everyone has his/her own style.


Messages In This Thread
how to retrieve the values of mulple list? - by El Forum - 01-17-2008, 07:17 AM
how to retrieve the values of mulple list? - by El Forum - 01-17-2008, 07:30 AM
how to retrieve the values of mulple list? - by El Forum - 01-17-2008, 02:07 PM
how to retrieve the values of mulple list? - by El Forum - 01-17-2008, 04:40 PM
how to retrieve the values of mulple list? - by El Forum - 01-18-2008, 02:32 AM
how to retrieve the values of mulple list? - by El Forum - 01-18-2008, 09:11 AM
how to retrieve the values of mulple list? - by El Forum - 01-18-2008, 09:33 AM
how to retrieve the values of mulple list? - by El Forum - 01-18-2008, 09:41 AM



Theme © iAndrew 2016 - Forum software by © MyBB