php - Compare and replace values in array -


i need compare 2 arrays , first array have 1 order , can´t change , in other array have different values , first array must compare id id of other array , , if id it´s same , take value , replace show in same order

for example :

$array_1=array("1a-dogs","2a-cats","3a-birds","4a-people"); $array_2=array("4a-walking","2a-cats"); 

the result in case want it´s :

"1a-dogs","2a-cats","3a-birds","4a-walking" 

if id in case 4a it´s same , entry must modificate , put value of other array , stay in same order

i no work me :

for($fte=0;$fte<count($array_1);$fte++) {   $exp_id_tmp=explode("-",$array_1[$fte]);     $cr_temp[]="".$exp_id_tmp[0]."";   }      for($ftt=0;$ftt<count($array_2);$ftt++) {   $exp_id_targ=explode("-",$array_2[$ftt]);   $cr_target[]="".$exp_id_targ[0]."";    }  /// here tried use array_diff , others no can results want  

how can results ?

maybe use array_udiff_assoc() function callback


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -