Jump to content

Array_push with desired Index ?


snowboarderz69

Recommended Posts

Hello everyone,

I'm trying to creat a Array with a desired Index but when i Try to choose my index I get the error : $my_array is not a array. Here's my code :

 

        
$strRequeteCours	=	"SELECT * FROM t_cours WHERE session IN (" . $idSession . ")";	
$strCours			=	mysql_query($strRequeteCours) or die (mysql_error());
$a_retourner		=	array();
          while ($a_cours		=	mysql_fetch_assoc($strCours)){
	array_push($a_retourner[$a_cours["id_cours"]],$a_cours["nom_cours"] . "    " . $a_cours["duree"] . "    " . $a_cours["ponderation"] . "<br/>" .    $a_cours["description_cours"]); 
}

 

So I want to push my info into a Array where the Index of the array equal my "id_cours". I alost tryed with the Index 1 to and it didn't worked.

 

Thanks alot !

 

Link to comment
https://forums.phpfreaks.com/topic/191664-array_push-with-desired-index/
Share on other sites

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.