matthewbauer Posted May 8, 2009 Share Posted May 8, 2009 I am use to other languages like Python and C and one part of PHP I don't understand is arrays. When I have a script that does something like this: $names = Array("Me", "Myself", "I"); echo $names[0]; I get an error along the lines of: Parse error: syntax error, unexpected '[', expecting ',' or ';'. So are there any alternatives to the sample script I have above? Link to comment https://forums.phpfreaks.com/topic/157325-array-fundamentals-in-php/ Share on other sites More sharing options...
Ken2k7 Posted May 8, 2009 Share Posted May 8, 2009 array, lowercased. Link to comment https://forums.phpfreaks.com/topic/157325-array-fundamentals-in-php/#findComment-829207 Share on other sites More sharing options...
matthewbauer Posted May 8, 2009 Author Share Posted May 8, 2009 array, lowercased. Ok, sorry what I really meant is when returning from a function like this: function ReturnNames(){ return array("Me", "Myself", "I"); } echo ReturnNames()[0]; Link to comment https://forums.phpfreaks.com/topic/157325-array-fundamentals-in-php/#findComment-829225 Share on other sites More sharing options...
The Little Guy Posted May 8, 2009 Share Posted May 8, 2009 function ReturnNames(){ $names = array("Me", "Myself", "I"); return $names; } $rname = ReturnNames(); echo $rname[0]; Link to comment https://forums.phpfreaks.com/topic/157325-array-fundamentals-in-php/#findComment-829229 Share on other sites More sharing options...
Mchl Posted May 8, 2009 Share Posted May 8, 2009 array, lowercased. Since when? Link to comment https://forums.phpfreaks.com/topic/157325-array-fundamentals-in-php/#findComment-829243 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.