• I’ve been delving into WordPress theming and I keep coming across an expression or two that I don’t understand, it’s this => It sort of seems to act like what it looks like, an arrow. I’m familiar with the standard less than/equal to <=, the greater than/equal to >=, but I have no idea what this expression means, or what function it performs. I’ve also seen a version with the minus sign ->.

    I know some basic php scripting, but I only ever see this thing in WordPress themes. What is it?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter claybaby

    (@claybaby)

    Is this a PHP question?

    Not a PHP guru, but I googled your question and found this:

    Masi => is the separator for associative arrays. In the context of that foreach loop, it assigns the key of the array to $user and the value to $pass.
    
    Example:
    
    $user_list = array(
        'dave' => 'apassword',
        'steve' => 'secr3t'
    );
    
    foreach ($user_list as $user => $pass) {
        echo "{$user}'s pass is: {$pass}\n";
    }
    // Prints:
    // "dave's pass is: apassword"
    // "steve's pass is: secr3t"
    
    Note that this can be used for numerically indexed arrays too.
    
    Example:
    
    $foo = array('car', 'truck', 'van', 'bike', 'rickshaw');
    foreach ($foo as $i => $type) {
        echo "{$i}: {$type}\n";
    }
    // prints:
    // 0: car
    // 1: truck
    // 2: van
    // 3: bike
    // 4: rickshaw

    https://stackoverflow.com/questions/1241819/what-does-mean-in-php

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    It’s used to associate properties and values in an array; https://www.w3schools.com/php/func_array.asp

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    I’ve also seen a version with the minus sign ->.

    That’s used to get properties of an object.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘syntax question’ is closed to new replies.