This is the code I used to get array key with single quote mark:
// 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;
Is there other better way to make it more effective?
1 Answer