[resolved] PHP Syntax? (2 posts)

  1. Tsalagi
    Posted 6 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;
    "options" => $styles),
    Thanks in advance

  2. s_ha_dum
    Posted 6 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);

Topic Closed

This topic has been closed to new replies.

About this Topic