$data = "{0,1,?page=1,открыть}, {1,1,files/word.doc,скачать}"; 

Need to get an array from strings

 "0,1,?page=1,открыть" "1,1,files/word.doc,скачать" 
  • It was easier to store json and Russian characters in base64. This nedomassiv was also in the same column in the database. Do not repeat my mistakes) - Mr. Black

1 answer 1

 $data = "{0,1,?page=1,открыть}, {1,1,files/word.doc,скачать}"; $arr=preg_split('/\{|\}(, *)?/',$data,-1,PREG_SPLIT_NO_EMPTY); var_dump($arr); 

Or

 $data = "{0,1,?page=1,открыть}, {1,1,files/word.doc,скачать}"; preg_match_all('/\{.*?}/',$data,$arr); var_dump($arr[0]); 

In this case, an array is returned in element 0 of which lies the array that is needed.

  • This is some kind of magic. Thank you, kind man :) - Mr. Black