Panjabel Posted September 26, 2008 Share Posted September 26, 2008 <?php $list1 = array("cv1","cv2","cv3"); $list2 = array("cv1s","cv2","cv3d"); foreach($list1 as $list) { //if $list exists in array $list2 i want to print it, else not to print it } ?> I've searched for this but i found, if i'm searching for "cv1" in "cv1" it finds it but if i'm searching for "cv1" in "cv1s" it doesn't Thanks in advance Link to comment https://forums.phpfreaks.com/topic/125921-search-string-in-array/ Share on other sites More sharing options...
GingerRobot Posted September 26, 2008 Share Posted September 26, 2008 Like this? $list1 = array("cv1","cv2","cv3"); $list2 = array("cv1s","cv2","cv3d"); foreach($list1 as $v1){ foreach($list2 as $v2){ if(strpos($v2,$v1) !== FALSE){ echo $v1.'<br />'; } } } Link to comment https://forums.phpfreaks.com/topic/125921-search-string-in-array/#findComment-651143 Share on other sites More sharing options...
Panjabel Posted September 26, 2008 Author Share Posted September 26, 2008 Well, if it exists, not to print it, if it doesn't exists, to print it. it is posible ?Thanks Link to comment https://forums.phpfreaks.com/topic/125921-search-string-in-array/#findComment-651145 Share on other sites More sharing options...
sasa Posted September 26, 2008 Share Posted September 26, 2008 look http://hr.php.net/array_intersect Link to comment https://forums.phpfreaks.com/topic/125921-search-string-in-array/#findComment-651207 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.