Explode and get a value in one line of code Explode and get a value in one line of code arrays arrays

Explode and get a value in one line of code


you could use stristr for this:

$foo = stristr($foo,":",true);

where true sets it to give you everything before the first instance of ":"


As an alternative to list(), you may use array_shift()

$foo = array_shift(explode(':', $foo));


Yes, it's posible to do using list:

list($foo) = explode(":", $foo);