Tsalagi
Member
Posted 2 years ago #
Just a quicky that I can't find any reference to. I'm working on a template and the php code has this syntax in it and I don't know what it means. What does -> and => do in the following code?
$getpag[$apage->ID] = $apage->post_title;
and
"options" => $styles),
Thanks in advance
s_ha_dum (was apljdi)
Member
Posted 2 years ago #
The -> is object syntax, so $apage->ID is pulling the ID element from the $apage object. If you look at, say, the wpdb object you'll see the same kind of thing.
The => is an assignment operator for arrays. You could do something like this:
$a = array();
$a['options'] = $styles;
$a['opt2'] = $hithere;
But you could also do the same thing like this:
$a = array('options' => $styles, 'opt2' => $hithere);