test - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of test.php

  1. <?php
  2. $orderby = '';
  3. $order = '';
  4. $temp_arr = [];
  5.  
  6. $arr = array (
  7.   0 =>
  8.   array (
  9.     'orderby' => 'title',
  10.     'order' => 'asc',
  11.   ),
  12.   1 =>
  13.   array (
  14.     'orderby' => 'name',
  15.     'order' => 'desc',
  16.   ),
  17.   2 =>
  18.   array (
  19.     'orderby' => 'ID',
  20.     'order' => 'asc',
  21.   ),
  22.  
  23.  
  24. );
  25.  
  26.  
  27. foreach($arr as $item) {
  28.    
  29.     foreach( $item as $k => $v ) {
  30.        
  31.         if($k === 'orderby') {
  32.            $orderby = $v;
  33.         }
  34.         if($k === 'order') {
  35.            $order = $v;
  36.         }
  37.         $temp_arr[$orderby] = $order;
  38.    
  39.     }
  40.    
  41. }
  42.  
  43. var_dump($temp_arr);
  44.  
File Description
  • test
  • PHP Code
  • 09 Jun-2023
  • 560 Bytes
You can Share it: