I found myself using this:
$var=(string)array_shift(array_values($item->xpath($s)));
where $s is an xpath search string and the return is an array of objects that contain strings.
It works, but I'm not sure it's the best way to get the data I want.
I could use a tempvar, but I wanted to avoid that.
Any suggestions?
array_valuesis useless here. With PHP 5.4 you can do$item->xpath($s)[0]$results = $item->xpath($s); $var = (string) $results[0];?syntax error, unexpected '[' in /home/... line 211when I tried your version. My php version might be slightly older than 5.4