0
これは私が単一引用符で配列のキーを取得するために使用されるコードです:既存の配列キーに一重引用符を追加する最も良い方法は何ですか?
// the array with key and value
$savedFilesIds = array("F564574"=>"none","F456735"=>"none","F4777"=>"none")
//$file_ids = implode(',',array_keys($savedFilesIds)); // without adding single quote mark for keys
// the way I used to adding single quote mark for keys
$file_ids = array();
foreach($savedFilesIds as $key=>$value){
$item = '\''.$key.'\''; // adding single quote mark here
array_push($file_ids , $item); // and then adding to array
}
$file_ids = implode(',',$file_ids); // get the key with single quote mark
echo $file_ids;
はそれをより効果的にするが、他のより良い方法ですか?