arrays

I seem to be having a problem with the code

[code]$stores = array(“2001”, “2002”, “2051”, “2052”, “2053”, “1501”, “1502”, “1503”, “1504”);
$work = ‘2001; 1501’;

$info = explode(’;’, $work);
for ($i = 0; $i < count($stores); $i++) {
// if(in_array($info[$i], $stores, true)) {
if(in_array($info[$i], $stores)) {
echo ‘’. $stores[$i] .’ [ Edit ]
‘;
} else {
echo ‘’. $stores[$i] .’
';
}
}[/code]

Result:
2001 [ Edit ]
2002 [ Edit ]
2051
2052
2053
1501
1502
1503
1504

What I am looking for is when $work is in the $stores array and they == eachother then put and edit link beside the store
and if there is a $stores at which the $work is not there then no edit button

what i would like to happen;
2001 [ Edit ]
2002
2051
2052
2053
1501 [ Edit ]
1502
1503
1504

thanks in advace

You’re taking the count() of $stores, but then loop through the $info array. Switch those around in your in_array() call and it should go well.

Btw, the result would have been different if you had used error_reporting().

Sponsor our Newsletter | Privacy Policy | Terms of Service