php - Multidimensional array Converting inside arrays to strings -
array ( [0] => array ( [0] => array ( [masteryid] => 6111 [rank] => 5 ) [1] => array ( [masteryid] => 6122 [rank] => 1 ) [2] => array ( [masteryid] => 6131 [rank] => 5 ) [3] => array ( [masteryid] => 6142 [rank] => 1 ) [4] => array ( [masteryid] => 6151 [rank] => 5 ) [5] => array ( [masteryid] => 6162 [rank] => 1 ) [6] => array ( [masteryid] => 6211 [rank] => 5 ) [7] => array ( [masteryid] => 6223 [rank] => 1 ) [8] => array ( [masteryid] => 6231 [rank] => 5 ) [9] => array ( [masteryid] => 6241 [rank] => 1 ) ) [1] => array ( [0] => array ( [masteryid] => 6114 [rank] => 5 ) [1] => array ( [masteryid] => 6123 [rank] => 1 ) [2] => array ( [masteryid] => 6131 [rank] => 5 ) [3] => array ( [masteryid] => 6142 [rank] => 1 ) [4] => array ( [masteryid] => 6211 [rank] => 5 ) [5] => array ( [masteryid] => 6223 [rank] => 1 ) [6] => array ( [masteryid] => 6231 [rank] => 5 ) [7] => array ( [masteryid] => 6241 [rank] => 1 ) [8] => array ( [masteryid] => 6251 [rank] => 5 ) [9] => array ( [masteryid] => 6262 [rank] => 1 ) ) [2] => array ( [0] => array ( [masteryid] => 6114 [rank] => 5 ) [1] => array ( [masteryid] => 6122 [rank] => 1 ) [2] => array ( [masteryid] => 6131 [rank] => 5 ) [3] => array ( [masteryid] => 6142 [rank] => 1 ) [4] => array ( [masteryid] => 6312 [rank] => 5 ) [5] => array ( [masteryid] => 6322 [rank] => 1 ) [6] => array ( [masteryid] => 6331 [rank] => 5 ) [7] => array ( [masteryid] => 6343 [rank] => 1 ) [8] => array ( [masteryid] => 6351 [rank] => 5 ) [9] => array ( [masteryid] => 6362 [rank] => 1 ) ) [3] => array ( [0] => array ( [masteryid] => 6111 [rank] => 5 ) [1] => array ( [masteryid] => 6122 [rank] => 1 ) [2] => array ( [masteryid] => 6131 [rank] => 5 ) [3] => array ( [masteryid] => 6141 [rank] => 1 ) [4] => array ( [masteryid] => 6151 [rank] => 5 ) [5] => array ( [masteryid] => 6162 [rank] => 1 ) [6] => array ( [masteryid] => 6312 [rank] => 5 ) [7] => array ( [masteryid] => 6322 [rank] => 1 ) [8] => array ( [masteryid] => 6331 [rank] => 5 ) [9] => array ( [masteryid] => 6343 [rank] => 1 ) ) [4] => array ( [0] => array ( [masteryid] => 6114 [rank] => 5 ) [1] => array ( [masteryid] => 6123 [rank] => 1 ) [2] => array ( [masteryid] => 6134 [rank] => 5 ) [3] => array ( [masteryid] => 6142 [rank] => 1 ) [4] => array ( [masteryid] => 6311 [rank] => 5 ) [5] => array ( [masteryid] => 6322 [rank] => 1 ) [6] => array ( [masteryid] => 6332 [rank] => 5 ) [7] => array ( [masteryid] => 6342 [rank] => 1 ) [8] => array ( [masteryid] => 6351 [rank] => 5 ) [9] => array ( [masteryid] => 6362 [rank] => 1 ) ) [5] => array ( [0] => array ( [masteryid] => 6111 [rank] => 5 ) [1] => array ( [masteryid] => 6122 [rank] => 1 ) [2] => array ( [masteryid] => 6134 [rank] => 5 ) [3] => array ( [masteryid] => 6142 [rank] => 1 ) [4] => array ( [masteryid] => 6211 [rank] => 5 ) [5] => array ( [masteryid] => 6223 [rank] => 1 ) [6] => array ( [masteryid] => 6231 [rank] => 5 ) [7] => array ( [masteryid] => 6241 [rank] => 1 ) [8] => array ( [masteryid] => 6251 [rank] => 5 ) [9] => array ( [masteryid] => 6261 [rank] => 1 ) ) [6] => array ( [0] => array ( [masteryid] => 6111 [rank] => 5 ) [1] => array ( [masteryid] => 6121 [rank] => 1 ) [2] => array ( [masteryid] => 6131 [rank] => 5 ) [3] => array ( [masteryid] => 6142 [rank] => 1 ) [4] => array ( [masteryid] => 6211 [rank] => 5 ) [5] => array ( [masteryid] => 6223 [rank] => 1 ) [6] => array ( [masteryid] => 6231 [rank] => 5 ) [7] => array ( [masteryid] => 6241 [rank] => 1 ) [8] => array ( [masteryid] => 6251 [rank] => 5 ) [9] => array ( [masteryid] => 6262 [rank] => 1 ) ) [7] => array ( [0] => array ( [masteryid] => 6211 [rank] => 5 ) [1] => array ( [masteryid] => 6221 [rank] => 1 ) [2] => array ( [masteryid] => 6231 [rank] => 5 ) [3] => array ( [masteryid] => 6241 [rank] => 1 ) [4] => array ( [masteryid] => 6312 [rank] => 5 ) [5] => array ( [masteryid] => 6323 [rank] => 1 ) [6] => array ( [masteryid] => 6331 [rank] => 5 ) [7] => array ( [masteryid] => 6343 [rank] => 1 ) [8] => array ( [masteryid] => 6351 [rank] => 5 ) [9] => array ( [masteryid] => 6361 [rank] => 1 ) ) [8] => array ( [0] => array ( [masteryid] => 6111 [rank] => 5 ) [1] => array ( [masteryid] => 6122 [rank] => 1 ) [2] => array ( [masteryid] => 6131 [rank] => 5 ) [3] => array ( [masteryid] => 6142 [rank] => 1 ) [4] => array ( [masteryid] => 6151 [rank] => 5 ) [5] => array ( [masteryid] => 6161 [rank] => 1 ) [6] => array ( [masteryid] => 6312 [rank] => 5 ) [7] => array ( [masteryid] => 6322 [rank] => 1 ) [8] => array ( [masteryid] => 6331 [rank] => 5 ) [9] => array ( [masteryid] => 6343 [rank] => 1 ) ) [9] => array ( [0] => array ( [masteryid] => 6211 [rank] => 5 ) [1] => array ( [masteryid] => 6223 [rank] => 1 ) [2] => array ( [masteryid] => 6231 [rank] => 5 ) [3] => array ( [masteryid] => 6241 [rank] => 1 ) [4] => array ( [masteryid] => 6312 [rank] => 5 ) [5] => array ( [masteryid] => 6322 [rank] => 1 ) [6] => array ( [masteryid] => 6332 [rank] => 5 ) [7] => array ( [masteryid] => 6343 [rank] => 1 ) [8] => array ( [masteryid] => 6352 [rank] => 5 ) [9] => array ( [masteryid] => 6363 [rank] => 1 ) ) )
how can convert array above array below.
the array above has 9 arrays inside. , have masteryid , ranks inside. want make them string. masteryid xx rank ++ masteryid xx rank ....
array ( [0] => 6111 xx 5 ++ 6122 xx 1 ++ 6131 xx 5 ++ 6142 xx 1 .... [1] => 6114 xx 5 ++ 6123 xx 1 ++ 6131 xx 5 ++ 6142 xx 1 .... .... [9] => 6221 xx 5 ++ 6223 xx 1 ++ 6231 xx 5 ++ .... )
i stuck code , trying 5 hours couldnt came here.
try :
$output = array(); foreach($array $value) { $s = ""; foreach($value $v) $s .= $v['masteryid'].' xx '.$v['rank'].' ++ '; $output[] = rtrim($s,' ++ '); }
i hope you.
Comments
Post a Comment