私は少し複雑な以下のコードを書いている。をカスケードする代わりに、以下のコードをless step内で減らすことが可能です()。どのようにこの文字列の操作コードを減らす
$countries='IN,US,AU,MY,TH,KR,TW'; //list country codes separated by comma
$countries=explode(',',$countries); //partition from ,
$countries=implode('\',\'',$countries); //add ' at start and end of the country code
$countries="'".$countries."'"; //add ' to first and last country code
$countries=explode(',',$countries); //create array by breaking it from ,
print_r($countries);
OUTPUT
アレイ([0] => 'IN' [1] => 'US' [2] => 'AU' [3] => 'MY' [4] => 'TH' [5] => 'KR' [6] => 'TW')出力以下等の
だから、最終的な配列をしたい、それはあなたの最初の文字列から、しかし、 '「「'値の周りにいるのですか? – Sean
おそらく、preg_replaceはループ内で – Andreas
を実行する可能性があります。この場合、uプリント値に "$ value"を追加すると、 –