Jump to content

2 arrays, 1 result back


MichelDS

Recommended Posts

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

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 !

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.