phpSensei Posted July 9, 2010 Share Posted July 9, 2010 Hello... Code is Self explainatory, is the following possible to do? Script: $arr = array(); array_push($arr, $something => "sdasd"); I keep getting an error Parse error: parse error in C:\wamp\www\uLoad\index.php on line 29 Quote Link to comment Share on other sites More sharing options...
phpSensei Posted July 9, 2010 Author Share Posted July 9, 2010 Ah solved nvm Quote Link to comment Share on other sites More sharing options...
joel24 Posted July 9, 2010 Share Posted July 9, 2010 are you trying to add another value to the array, or create a double array?! this will work, adding "sdasd" as a value in the array. $arr = array(); array_push($arr, "sdasd"); Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted July 9, 2010 Share Posted July 9, 2010 So obviously its not possible. The second parameter needs to be a string, array, object, etc. not a construct that only applies to array definition or foreach expression. Just use the normal: $arr[$something] = "sdasd"; Quote Link to comment Share on other sites More sharing options...
phpSensei Posted July 9, 2010 Author Share Posted July 9, 2010 $arr[] = array("sdfdf"=>"sdfsd"); its the only way.. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.