I got a record set row. how can I read all the record sets to form a two-dimensional array.

Source: Internet
Author: User
I got a record set row. how can I read all the record sets to form a two-dimensional array. This post was last edited by qq914260102 at 10:08:13, January 14 ,.

For example, I have one hundred records in a record set $ row.

For ($ k = 0; $ k <$100; $ k ++ ){
$ Arr = array ($ a [$ k], $ B [$ k], $ c [$ k]);
Print_r ($ arr );
}
Now I can loop these one hundred entries into one hundred unique arrays. now I want to turn this into a two-dimensional array and write and send it ..


Reply to discussion (solution)

for($k=0;$k<$100;$k++){   $arr[]=array($yid[$k],$title[$k],$link[$k]));   print_r($arr);}

$ Array1 = array ('1', '2', '3'); $ array2 = array ('1', '2', '3 '); $ arr = array (); for ($ k = 0; $ k <100; $ k ++) {// here not $100 $ arr [] = array ($ array1 [$ k], $ array2 [$ k]);} echo"
";print_r($arr);

I will go. The color is incorrect.

$ Array1 = array ('1', '2', '3'); $ array2 = array ('1', '2', '3 '); $ arr = array (); for ($ k = 0; $ k <100; $ k ++) {$ arr [] = array ($ array1 [$ k], $ array2 [$ k]);} echo"
";print_r($arr);

While $ row
{
$ Arr [$ row ["id"] = $ row ["name"];
}

I just found this method the most convenient

For example, I have one hundred records in a record set $ row.

For ($ k = 0; $ k <$100; $ k ++ ){
$ Arr = array ($ a [$ k], $ B [$ k], $ c [$ k]);
Print_r ($ arr );
}
Now I can loop these one hundred entries into one hundred unique arrays. now I want to turn this into a two-dimensional array and write and send it ..

The output result is as follows:
Array ([0] => a1 [1] => b1 [2] => c1)
Array ([0] => asdf2 [1] => b2df [2] => b2sd)
Array ([0] => a3 [1] => b3 [2] => b6)
Array ([0] => a4 [1] => b4 [2] => sdfs)

I want this result .,
Yes $ test = Array ([0] => a1 [1] => b1 [2] => c1 ), array ([0] => asdf2 [1] => b2df [2] => b2sd ), array ([0] => a3 [1] => b3 [2] => b6 ), array ([0] => a4 [1] => b4 [2] => sdfs)

You are talking about two-dimensional arrays.

foreach($row as $val){    print_r($val);}

You are talking about two-dimensional arrays.

foreach($row as $val){    print_r($val);}


Find the specific code.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.