fork(1) download
  1. <?php
  2.  
  3. function test($str, $first=true) {
  4. if (!is_array($str)) $result = "<li>$str</li>";
  5. else foreach ($str as $key => $value) $result .= test($value, false);
  6. if ($first) echo "<ol>$result</ol>";
  7. else return $result;
  8. }
  9.  
  10. test("apple");
  11. echo "\n";
  12. test(array("apple","orange","pear"));
  13.  
  14. ?>
Success #stdin #stdout 0.02s 13112KB
stdin
Standard input is empty
stdout
<ol><li>apple</li></ol>
<ol><li>apple</li><li>orange</li><li>pear</li></ol>