Reputation: 1257
function get( $str ){
$matches = $this->xml->xpath("/conf/item [@name= \"$str\"]");
if (count($matches)) {
$this->lastmatch = $matches[0];
return (string) $matches[0];
}
I can't find any information about what the last line of this code does.
What does this (string) $matches[0] piece do?
As I can guess, it returns the zero element of the array as a string. But I didn't find any mention about this syntax in the docs.
Am I right?
And it will be great if you provide me with a link where I can read about this.
Upvotes: 0
Views: 55
Reputation: 10724
You can read about it here: http://php.net/manual/en/language.types.type-juggling.php
It is called type juggling, because php does not have explicit types.
You can use the following type castings:
(int), (integer) - cast to integer
(bool), (boolean) - cast to boolean
(float), (double), (real) - cast to float
(string) - cast to string
(array) - cast to array
(object) - cast to object
(unset) - cast to NULL (PHP 5)
Upvotes: 2