使用php中的数组变量拆分并存储到列表中

I have a number that is get from a web page, such that $number=12-34-33-87-54-................ and so on.

$number may have two numbers like $number=12-34 or it may have 3 numbers like $number=12-34-33 or it may have more numbers like $number=12-34-33-87-54-.......... and so on.

I want to split it by '-' and want to store in an array. like array(12,34,33,.....)

I used the code given below but it doesn't work.

<?php
$a=array();
list($a)=split('-',$number);
foreach($a as $v)
{
echo $v;
}
?>

Plz tell me how can i split this?

$parts = explode('-',$number);

Although split() is depracated, explode will do the trick for you

<?php
$a=explode('-',$number);
foreach($a as $v)
{
    echo $v;
}
?>

It assumes that a , is the default, so you can use it on a CSV without having to specify.

Php explode is what you need here.

$arrayOfTokens = explode('-',$number);

explode returns an array of string, as stated in the documentation provided.

explode will return this array without any interfere from your side

$returnedArray = explode('-',$number);

this should work fine for you