$array = array('lastname', 'email', 'phone');echo "'" . implode("','", $array) . "'";
You could use array_map():
array_map()
function add_quotes($str) { return sprintf("'%s'", $str);}$csv = implode(',', array_map('add_quotes', $array));
DEMO
Also note that there is fputcsv if you want to write to a file.
fputcsv
$ids = sprintf("'%s'", implode("','", $ids ) );