vidhu Posted February 23, 2010 Share Posted February 23, 2010 Hello I have doubt about foreach loop foreach($refnr as $new) { foreach($senr as $old) { if($new=$old) { } } } THIS IS THE CODE $refnr ,$senr are arrats.i want ti check the element in the $refnr are equal to$senr..... [ Quote Link to comment https://forums.phpfreaks.com/topic/193106-foreach/ Share on other sites More sharing options...
jl5501 Posted February 23, 2010 Share Posted February 23, 2010 can you post some real example code with some real example array contents, and someone here will be able to help you Quote Link to comment https://forums.phpfreaks.com/topic/193106-foreach/#findComment-1016958 Share on other sites More sharing options...
mapleleaf Posted February 23, 2010 Share Posted February 23, 2010 $i = 0 ; foreach($refnr as $new){ if ($new == $senr[$i]) { $i++; //do something } } Quote Link to comment https://forums.phpfreaks.com/topic/193106-foreach/#findComment-1016959 Share on other sites More sharing options...
wildteen88 Posted February 23, 2010 Share Posted February 23, 2010 Could you post some example data for both arrays. I cant understand clearly what you're trying to do. But from what I can tell, you're basically wanting to check if an item in $refnr is in the array $senr?if thats the case then the function in_array meybe what you're after. Without knowing how your arrays are constructed and what they contain I cant tell you exactly what to do. Quote Link to comment https://forums.phpfreaks.com/topic/193106-foreach/#findComment-1016961 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.