Skip to content

Instantly share code, notes, and snippets.

@tadasuke
Created June 22, 2015 06:26
Show Gist options
  • Save tadasuke/e1f340ca7906a329405d to your computer and use it in GitHub Desktop.
Save tadasuke/e1f340ca7906a329405d to your computer and use it in GitHub Desktop.
配列の値が数値だったら文字列にする(多次元配列対応) ref: http://qiita.com/tadasuke/items/68bfd47ee7b2e1deb175
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