PHP explode string -


i have string: 0|dy1497oryosldy932oslcph|1|0|0

and need explode that:

0| dy1497 ory osl dy932 osl cph |1|0|0

$string1 = 'dy1497'; $string2 = 'ory'; $string3 = 'osl'; $string4 = 'dy932'; $string5 = 'osl'; $string6 = 'cph'; 

i searched, find how explode when text separated /, -, etc. ideas?

the best choice regex:

if (preg_match('/|(.{6})(.{3})(.{3})(.{5})(.{3})(.{3})|/', $string, $matches)) {     echo $matches[1];     echo $matches[2];     echo $matches[3];     echo $matches[4];     echo $matches[5];     echo $matches[6]; } 

this divides string length in characters. may need modify needed. see http://regular-expressions.info


Comments

Popular posts from this blog

c# - SelectList with Dictionary, add values to the Dictionary after it's assigned to SelectList -

how can i manage url using .htaccess in php? -

ios - I get the error Property '...' not found on object of type '...' -