I want to do explode(" ",$q[2])[1] where $q[2] is a string reading "question 1" but I keep getting errors saying that a comma or semicolon were expected instead of the right facing square bracket after the explode "[1]". I can use this syntax when the string isn't an array position so is there a shorthand way of doing this instead of making some temp variable and exploding it?
-
3This will not work if your php version is < 5.4cornelb– cornelb2014-02-18 21:03:50 +00:00Commented Feb 18, 2014 at 21:03
-
Upgrade or $foo = explode(" ", $q[1]);$foo[1]; Consider if explode is really what you need..user924016– user9240162014-02-18 21:05:20 +00:00Commented Feb 18, 2014 at 21:05
-
Ahh, thank you. I just moved to a new hosting environment and neglected to think of the php version.Craig Lafferty– Craig Lafferty2014-02-18 21:06:08 +00:00Commented Feb 18, 2014 at 21:06
-
possible duplicate of PHP syntax for dereferencing function resultsalathe– salathe2014-02-18 21:20:01 +00:00Commented Feb 18, 2014 at 21:20
Add a comment
|