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
Post a Comment