The var_dump of the associative array $myArray is as follows:
array (size=522)
0 =>
array (size=3)
'id' => int 1
'url' => string 'introduction' (length=12)
'title' => string 'Introduction' (length=12)
1 =>
array (size=3)
'id' => int 2
'url' => string 'first_steps' (length=11)
'title' => string 'First steps' (length=11)
2 => ...
When I assign the values of elements in the associative array to a function, to perform some string manipulation, I get an error:
"Catchable fatal error: Argument 1 passed to doStringManipulation() must be an instance of string, string given, ..."
The string manipulation is called inside a foreach loop:
foreach($myArray as $row){
...
$s = doStringManipulation((string) $row['url']); // triggers error
...
}
function doStringManipulation(string str){
...
return $result; // string
}
Whether or not I cast $row['url'] to string doesn't make a difference. I always get the error, even though var_dump confirms that the element value is a string.
What am I missing here?
Thanks!