Last active
August 29, 2015 14:06
-
-
Save rxnlabs/9c19ec64d08eed38d086 to your computer and use it in GitHub Desktop.
PHP - Get the first value from a multidimensional array where the first value may be a serialized array.
This file contains hidden or 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 | |
/** | |
Get first value from multidimensional serialized array | |
*/ | |
function get_value_from_multidimensional_array( $possible_array ){ | |
if( is_array($possible_array) ){ | |
$maybe_serialized = @unserialize($possible_array[0]); | |
if( $maybe_serialized !== false ){ | |
$possible_array[0] = $maybe_serialized; | |
} | |
$value = $possible_array[0]; | |
$testing = @unserialize($value); | |
if( $testing !== false ){ | |
$value = $testing; | |
} | |
$possible_array = get_value_from_multidimensional_array( $value ); | |
} | |
return $possible_array; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment