Venciity

Dump variable

Aug 12th, 2014
503
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.26 KB | None | 0 0
  1. <?php
  2. $tests = array(
  3.     "hello",
  4.     15,
  5.     array(1,2,3),
  6.     1.234,
  7.     (object)[2,34]
  8. );
  9.  
  10. foreach ($tests as $element) {
  11.     if (is_numeric($element)) {
  12.         echo var_dump($element), "\n";
  13.     } else {
  14.         echo gettype($element), "\n";
  15.     }
  16. }
Add Comment
Please, Sign In to add comment