Example code sharing for PHP two-dimensional array rectangle transpose

Source: Internet
Author: User
PHP two-dimensional array rectangle transpose instance

<?php    //two-D array transpose  //define a two-dimensional array  $arr =array (Array (), Array (4,5,6));  Defines an array to place the transpose data  $arr 1=array ();  Traverse Echo before transpose  "before transpose:";  for ($i =0; $i <count ($arr), $i + +) {for        ($j =0; $j <count ($arr [$i]); $j + +) {          echo $arr [$i];          }    echo "";  }  echo "Transpose before and after:";  Determine the number of lines after the appliance for  ($j =0; $j <count ($arr [0]), $j + +) {    $arr 1[$j]=array ();  }  for ($i =0; $i <count ($arr), $i + +) {for        ($j =0; $j <count ($arr [$i]); $j + +) {          $arr 1[$j] [$i]= $arr [$i] [$j];      echo $arr;    }  }  Traverse after transpose: for  ($k =0; $k <count ($arr 1); $k + +) {for        ($l =0; $l

The above is the PHP two-dimensional array rectangle transpose instance code share content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!

  • Related Article

    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.