jeroen - 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 jeroen.php

  1. <?php
  2.         //Enter your code here, enjoy!
  3.  
  4. $array = array(0 => array('id' => 10, 'title' => "PHP code tester Sandbox Online"),  
  5.               1 => array('id' => 15, 'title' => "bar", 5 , 5 => 89009), 
  6.               2 => array('id' => 20, 'title' => "Random Stuff: " . rand(100,999)),
  7.               );
  8.     
  9.     $newArray = array();          
  10. foreach( $array as $value ){
  11.     $newArray[$value['id']] = $value['title'];
  12.     
  13.     //$newArray[] = array(
  14.     //    $value['id'] => $value['title']
  15.     //    );
  16. }
  17.  
  18. print_r($newArray);
  19.  
  20. /*
  21.  Array
  22. (
  23.     [10] => PHP code tester Sandbox Online
  24.     [15] => bar
  25.     [20] => Random Stuff: 276
  26. )
  27. */
File Description
  • jeroen
  • PHP Code
  • 18 Oct-2019
  • 637 Bytes
You can Share it: