-4

I have a string like this |casio|watch|men| in an xml. I want to explode this and i need output like this : $brand = "casio"; $cat = "watch";.

i used these codes but it doesnt helped me

<?php

$string = '|casio|watch|men|'; 

$string = explode('-',$string);

var_dump($string); 

echo $string[0]; 

echo $string[1];

?>
Emre Y
  • 51
  • 1
  • 7

1 Answers1

0

your trying to separate the string using '-' while your string doesnt contain any... in your case you should explode the using '|' example

$string = explode('|',$string);
Iatrarchy
  • 349
  • 3
  • 12