Created
June 22, 2015 06:26
-
-
Save tadasuke/e1f340ca7906a329405d to your computer and use it in GitHub Desktop.
配列の値が数値だったら文字列にする(多次元配列対応) ref: http://qiita.com/tadasuke/items/68bfd47ee7b2e1deb175
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
public static function int2stringByArray( array $array ) { | |
$responseArray = array(); | |
foreach ( $array as $key => $value ) { | |
// 値が配列の場合 | |
if ( is_array( $value ) === TRUE ) { | |
$responseArray[$key] = self::int2stringByArray( $value ); | |
// 値がintの場合 | |
} else if ( is_int( $value ) === TRUE ) { | |
$responseArray[$key] = (string)$value; | |
} else { | |
$responseArray[$key] = $value; | |
} | |
} | |
return $responseArray; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment