0

I have some entities such as:

یکشبه، 20 فروردین (از 390000 تومان)

I want to have the "20 فروردین" at first, then separate them into '20' and 'فروردین'.how to do such thing. speciallym I am wondering for the regex I must use in PHP for the first level. thanks.

mrmrn
  • 65
  • 4
  • 13

2 Answers2

0
$str = ' یکشبه، 20 فروردین (از 390000 تومان)';
$str = explode(' ',$str);
$date  = $str[1].$str[2];
$price = $str[5];

Use explode if this string not very complex!

Mahmoud.Eskandari
  • 1,460
  • 3
  • 20
  • 32
0

I have a new Idea after reading this and wrote this pieces of code:

<php
    function multiexplode ($delimiters,$string) {
    $ready = str_replace($delimiters, $delimiters[0], $string);
    $launch = explode($delimiters[0], $ready);
    return  $launch;
}


$mytext = " یکشبه، 20 فروردین (از 390000 تومان)";
$myexploded = multiexplode(array("،","("),$mytext);
print_r($myexploded);



?>
mrmrn
  • 65
  • 4
  • 13