There is a line like text1-text2-text3-text4

It is necessary to assign values ​​to it from variables, the values ​​themselves are separated by the symbol -

It should be:

$a = text1; $b = text2; $c = text3; $d = text4; 

How to do?

  • explode () not suitable? - Deonis

2 answers 2

 $str = 'text1-text2-text3-text4'; $arr = explode('-', $str); list($a, $b, $c, $d) = $arr; 
     list($a,$b,$c,$d)=explode('-','text-text-text-text');