MichelDS Posted May 11, 2012 Share Posted May 11, 2012 Perhaps a simple task... I did ASP coding before, now I'm into PHP. So I'm a newbie in PHP. 2 arrays : $array1 = array("1","2","3","4"); and $array2 = array("1","2"); In array2 you'll find the numbers that need to be excluded from array1. So I should have als result 3 and 4. I tried since 2 days now and can only check and exclude 1 number from array2 butnot dynamical ! $ii = 1; foreach( $arrayLordervalue as $value ) { if( $value == 1 )continue; //komma's tussen de cijfers plaatsen if($ii == 1){ $values[$ii] = $value;} else { $values[$ii] = ",". $value; } $value2= $value2.$values[$ii]; $ii++; } echo $value2; Gives me 2,3,4. I'm completely stuck ! I tried foreach, for ($n...),while... bah what's left ? Link to comment https://forums.phpfreaks.com/topic/262407-2-arrays-1-result-back/ Share on other sites More sharing options...
PFMaBiSmAd Posted May 11, 2012 Share Posted May 11, 2012 <?php $array1 = array("1","2","3","4"); $array2 = array("1","2"); $diff = array_diff($array1,$array2); print_r($diff); // use the content in the $diff array an way you want here... Link to comment https://forums.phpfreaks.com/topic/262407-2-arrays-1-result-back/#findComment-1344784 Share on other sites More sharing options...
MichelDS Posted May 11, 2012 Author Share Posted May 11, 2012 Well be damn..d ! PHP has seem to have so many functions, I didn't thought to take a look at those functions ! Now I know it's in my own interest ! Thank you PFMaBiSmAd ! -> http://be2.php.net/manual/en/book.array.php I'll use this site quiet often now ! Link to comment https://forums.phpfreaks.com/topic/262407-2-arrays-1-result-back/#findComment-1344790 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.