Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
012A345B67Z89任意の文字 (AZ) で展開する必要があるような文字列があります。
012A345B67Z89
私が探している結果は次のようなものです:
$str = '012A345B67Z89'; $result = explode(range('A','Z'),$str); print_r($result);
そして得る:
array( [0] = 012 [1] = 345 [2] = 67 [3] = 89 )
理想的にはphpで。
preg_split を試してください:
$str = '012A345B67Z89'; $result = preg_split("/[a-z]/i",$str); print_r($result);
これにより、必要な正確な出力が得られるはずです(コンマを除く):
Array ( [0] => 012 [1] => 345 [2] => 67 [3] => 89 )