PHPで文字列を分割する方法について
I have a string
$data = "Model:Galaxy Nexus SystemVersion:4.3 AppVersionCode:78 AppVersionName:3.140801.4";
I Split
$a = “Model:Galaxy Nexus”、
$b = “SystemVersion:4.3”、
$c = “AppVersionCode:78”、
$d = “AppVersionName: 3.140801. 4"、
何か良い方法はありますか?
------解決策のアイデア----------------------
$data = "Model:Galaxy Nexus SystemVersion:4.3 AppVersionCode:78 AppVersionName:3.140801.4";<br />$ar = preg_split('/(\w+:)/', $data, -1, PREG_SPLIT_NO_EMPTY <br><font color='#FF8000'>------解决思路----------------------</font><br> PREG_SPLIT_DELIM_CAPTURE);<br />$ar = array_map('join', array_chunk($ar, 2));<br />print_r($ar);
Array<br />(<br /> [0] => Model:Galaxy Nexus <br /> [1] => SystemVersion:4.3 <br /> [2] => AppVersionCode:78 <br /> [3] => AppVersionName:3.140801.4<br />)<br /><br />