phpstrpos

What does strpos do?


I understand that this foreach() statement is printing out the field 'name_first' from every item in the array that was fed to it...

foreach ($data as $author) { 
    print get('name_first', $author) . 
    " " . get('emailaddress', $author) .
    "<br/>";
    if(strpos($author['emailaddress'], ">")) { 
        $sp->update($listName, $author['id'], array('emailaddress'=> email_from_link($author['emailaddress'])));
    }

But can someone just explain what the last if statement is doing? It really doesn't make any sense to me.

if(strpos($author['emailaddress'], ">")) { 
    $sp->update($listName, $author['id'], array('emailaddress'=> email_from_link($author['emailaddress'])));

Solution

  • It's checking for the character > in the string $author['emailaddress'] after the first character.

    If > exists, then update the array $sp with the values specified between the parentheses.