php array item separate to another array -


i have array.in array have 156 item.my desired output format

{     "status": "ok",     "message": "data show successful",     "allresult": [         {             "id": "",             "title": "yes/no",             "details": "text"         } } 

first 0-19 column data shows "status": "ok", "message": "data show successful",

also last 2 column value shows same main complex column 20 155 these data goes allresult array here every 9 column shows

{     "id": "",     "title": "yes/no",     "details": "text" } 

lets describe column 20 155 have same type data in pair of every 9 column have same type data

  • possession
  • possession___length
  • open_cary
  • open_carry_length
  • concealed
  • concealed_length
  • concealed_w__ccw_required
  • concealed_w__ccw_required_length
  • notes

now our allresult output 20 37 number columns

"allresult": [     {        " possession": "here value of 20",        "possession___length": " here value of 21",        " open_cary ": " here value of 22 "        notes     },     {         " possession": "here value of 29",         "possession___length": " here value of 30",         " open_cary ": " here value of 31"        notes     } } 

i can retrieve data , can show json array output cant separate column 20 155 data every 9 column

retrieve data

while($row = mysql_fetch_assoc($result))  {     $info[]=$row; }  $output = array( 'result' =>$info);  echo json_encode($output); 

what array_chunk()? lets set size of each chunk

array_chunk — split array chunks

description

array array_chunk ( array $array , int $size [, bool $preserve_keys = false ] ) chunks array arrays size elements. last chunk may contain less size elements.

http://www.php.net/manual/en/function.array-chunk.php


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -