Skip to content

Instantly share code, notes, and snippets.

@chillbits-legacy
Created January 27, 2016 19:22
Show Gist options
  • Save chillbits-legacy/45a0eceaf1b3e3d80495 to your computer and use it in GitHub Desktop.
Save chillbits-legacy/45a0eceaf1b3e3d80495 to your computer and use it in GitHub Desktop.
Convert multi dimension array to 1 dimension array
<?php
/**
* Convert multi dimension array to 1 dimension array. Use this function when you need to convert
* wpdb results array to one dimension array
*
* @since 1.4.1
* @return string
*/
function flatten($v) {
if(count($v, COUNT_RECURSIVE) !== count($v)) {
$v = array_map('current', $v);
}
return $v;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment