I'm trying to debug a Drupal template and don't understand what this line of code does: if(is_array($url)) $url = $url[1];
If the $url variable is an array it will convert it to whatever is in the second element of the array (position 1) - probably a string.
if(is_array($url)) //tests to see if the varaible is an array $url = $url[1]; //if $url is an array, than $url will be converted to string with the value from the $url array from position 1. Eg.: $url[0]="hello" $url[1]="man" $url[2]="what are you doing?" if the array looks like that, after you execute the piece of code from above, you will get : $url=$url[1] -> $url="man" Hope it helps, Vlad
Ok, got it. It confused me seeing an array set equal to an element of the array. But the result is it converts the array to a string. Thanks guys.
PHP is not a typed language, array variables can become strings and so on. Read http://us3.php.net/manual/en/language.types.type-juggling.php for more info.