Split into two variables?

Latox picture Latox · Jan 19, 2011 · Viewed 21k times · Source

Say I have the following: "44-xkIolspO"

I want to return 2 variables:

$one = "44";
$two = "xkIolspO";

What would be the best way to do this?

Answer

Chandu picture Chandu · Jan 19, 2011

Try this:

list($one, $two) = split("-", "44-xkIolspO", 2);

list($one, $two) = explode("-", "44-xkIolspO", 2);