Emmash Posted October 8, 2008 Share Posted October 8, 2008 Hi, I'm having a problem with array's functions <?php //Making the list of the differents arrays if($cpt_couleur+1<count($_POST["couleur"])){ $liste_tableaux_couleur.=${"tab_resultat_couleur".$cpt_couleur}.","; } else{ $liste_tableaux_couleur.=${"tab_resultat_couleur".$cpt_couleur}; } //Keeping only the numbers that are present in each table if(count($_POST["couleur"])>1){ $tab_resultat_couleur=array_merge(array_intersect($liste_tableaux_couleur)); } else{ $tab_resultat_couleur=$liste_tableaux_couleur; }?> The problem is that array_intersect needs 2 parameters to work... I've also tried with dynamic variables but I think I code the wrong thing 'cause it didn't solve my problem... Is there any way to just write the content of the variable $liste_tableaux_couleur in the function array_intersect... something that would execute the line like : <?php $tab_resultat_couleur=array_merge(array_intersect($tab_resultat_couleur0,$tab_resultat_couleur1,$tab_resultat_couleur2)); ... ?> Thanks a lot!!!! Marie-Hélène (edited by kenrbnsn to add tags) Link to comment https://forums.phpfreaks.com/topic/127558-problem-with-arrays/ Share on other sites More sharing options...
Emmash Posted October 9, 2008 Author Share Posted October 9, 2008 Hi everyone, a man on another forum helps me get my answer.. so here it is : eval( '$tab_resultat_couleur = array_merge(array_intersect(' . $liste_tableaux_couleur . '));' ); Have a nice day! Marie-Hélène Link to comment https://forums.phpfreaks.com/topic/127558-problem-with-arrays/#findComment-660787 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.