tags:

views:

79

answers:

2

I have this:

$dataList = "*one*two*three*";
$list = explode("*", $dataList);
echo"<pre>";print_r($list);echo"</pre>";

which outputs:

> Array (
>     [0] => 
>     [1] => one
>     [2] => two
>     [3] => three
>     [4] =>  )

How do I strip the fist and last * in the string before exploding?

+3  A: 
trim($dataList, "*")
reko_t
+4  A: 

Using trim:

trim($dataList, '*');

This will remove all * characters (even if there are more than one!) from the end and the beginning of the string.

nikic