Created
January 27, 2016 19:22
-
-
Save chillbits-legacy/45a0eceaf1b3e3d80495 to your computer and use it in GitHub Desktop.
Convert multi dimension array to 1 dimension array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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