I don't mean for this question to be about Python vs PHP but about languages in general. I use Python and PHP as examples because I know them.
In Python we can do mytoken = mystring.split(mydelimiter)[1]
, accessing the list returned by str.split
without ever assigning it to a list.
In PHP we must put the array in memory before accessing it, as in $mytokenarray = explode($mydelimiter, $mystring); $mytoken = $mytokenarray[1];
. As far as I know it is not possible to do this in one statement as in Python.
What is going on behind this difference?