# arrays

**URL:** <https://www.phphelp.com/t/arrays/11106>\
**Category:** General PHP Help\
**Created:** [March 28, 2008, 9:37pm UTC](https://www.phphelp.com/t/arrays/11106 "2008-03-28T21:37:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hershal](https://www.phphelp.com/letter_avatar_proxy/v4/letter/h/ad7895/32.png) [@hershal](https://www.phphelp.com/u/hershal)\
**Post date:** [March 28, 2008, 9:37pm UTC](https://www.phphelp.com/t/arrays/11106/1 "2008-03-28T21:37:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Zyppora](https://www.phphelp.com/letter_avatar_proxy/v4/letter/z/76d3ee/32.png) [@Zyppora](https://www.phphelp.com/u/Zyppora)\
**Post date:** [March 31, 2008, 8:52am UTC](https://www.phphelp.com/t/arrays/11106/2 "2008-03-31T08:52:41Z")

</div>

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().
