Welcome Guest, Not a member yet? Register   Sign In
Exploding Array Elements... Using explode TWICE
#5

[eluser]richthegeek[/eluser]
Sure, I've added comments to each line to explain it a bit better;

Code:
$array = explode( ",", $str );
foreach( $array as $key=>$value )                 // foreach without {} wrap, as it is only one line
    $array[ $key ] = strpos( $value, "/" ) ?        // this form is the "ternary operator" where "return = expression ? if true : if false;"
                explode( "/", $value ) :     // this is if the $value contains a "/", so returns the second explosion
                $value;                // this is when there is no "/", so returns the original value


Messages In This Thread
Exploding Array Elements... Using explode TWICE - by El Forum - 04-26-2010, 12:24 AM
Exploding Array Elements... Using explode TWICE - by El Forum - 04-26-2010, 12:38 AM
Exploding Array Elements... Using explode TWICE - by El Forum - 04-26-2010, 12:48 AM
Exploding Array Elements... Using explode TWICE - by El Forum - 04-26-2010, 01:08 AM
Exploding Array Elements... Using explode TWICE - by El Forum - 04-26-2010, 01:12 AM
Exploding Array Elements... Using explode TWICE - by El Forum - 04-26-2010, 01:43 AM



Theme © iAndrew 2016 - Forum software by © MyBB