ARRAY_PUSH with $key

From: Date: Thu, 18 Jul 2002 19:40:58 +0000
Subject: ARRAY_PUSH with $key
Groups: php.general 
Request: Send a blank email to php-general+get-108322@lists.php.net to get a copy of this message
Hey all, Does anybody know of a way to push an element onto an array with a specific key? What I am trying to do is create a dynamically created associative array. Here is a sample print_r of what an array would look like: Array ( [default] => css/default.css [forms] => css/forms.css ) I have tried array_push, but can't seem to get the results I am looking for. i.e.: <? array_push($samp, "$key"=>"$value"); // this throws an error array_push($samp, array("$key"=>"$value")); // doesn't give the results i'm looking for /* output from second array_push Array ( [0] => Array ( [default] => css/default.css ) [1] => Array ( [forms] => css/forms.css ) )*/ ?> If anyone can point me in the right direction, I would appreciate any help you can give me. -- Joshua E Minnie/Webmaster josh@acsurf.net Phone: 616.276.9690 Fax: 616.342.8750 Nextel: 616.862.2847 "Don't work for recognition, but always do work worthy of recognition."

« previous php.general (#108322) next »