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..... [ 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 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 } } 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. Link to comment https://forums.phpfreaks.com/topic/193106-foreach/#findComment-1016961 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.