How can I break an outer loop with PHP?

You can using just a break-n statement:

foreach(...)
{
    foreach(...)
    {
        if (i.name == j) 
            break 2; //Breaks 2 levels, so breaks outermost foreach
    }
}

If you're in php >= 5.3, you can use labels and gotos, similar as in ActionScript:

foreach (...)
{        
    foreach (...)
    {
        if (i.name == j) 
            goto top;
    }
}
top:

But goto must be used carefully. Goto is evil (considered bad practice)


In the case of 2 nested loops:

break 2;

http://php.net/manual/en/control-structures.break.php


PHP Manual says

break accepts an optional numeric argument which tells it how many nested enclosing structures are to be broken out of.

break 2;