Skip to content

Instantly share code, notes, and snippets.

@antom
Last active March 16, 2020 12:07
Show Gist options
  • Save antom/680600a3bb83267dea80 to your computer and use it in GitHub Desktop.
Save antom/680600a3bb83267dea80 to your computer and use it in GitHub Desktop.
A quick method to quote the values of an array using implode/explode
<?php
function quote_array_values($array) {
return explode(',', sprintf(
'"%s"',
implode('","', $array)
));
}
$params = array(
'one',
'two',
'three',
);
$output = array(
'original' => $params,
'quoted' => quote_array_values($params),
);
echo '<pre>', print_r($output, 1), '</pre>';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment