daily pastebin goal
20%
SHARE
TWEET

Untitled

a guest Aug 19th, 2018 52 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
  1. Prevent printing key indexes while printing the value - PHP
  2. array(
  3.   'Home' => array(
  4.     'About',
  5.     'Contact'
  6.   ),
  7.   'News'
  8. );
  9.    
  10. function show($arr){
  11.     foreach($arr as $key => $value){
  12.       echo "n<ul>n<li>n" . $key;
  13.       if( ! empty($value)){
  14.         if(is_array($value)){
  15.           show($value);
  16.         }else{
  17.           echo $value;
  18.         }
  19.       }
  20.       echo "n</li>n</ul>n";
  21.     }
  22. }
  23.    
  24. Home
  25.   0About
  26.   1Contact
  27. 0News
  28.    
  29. array(
  30.   'Home' => array(
  31.     'About' => **array()**,
  32.     'Contact' => **array()**
  33.   ),
  34.   'News' => **array()**
  35. );
  36.    
  37. function show($arr){
  38.      foreach($arr as $key => $value){
  39.        echo "n<ul>n<li>";
  40.        if( ! empty($value)){
  41.          if(is_array($value)){
  42.           echo 'n'.$key;
  43.            show($value);
  44.          }else{
  45.            echo $value;
  46.          }
  47.        }
  48.        echo "n</li>n</ul>n";
  49.      } }
  50.    
  51. function show($arr){
  52. foreach($arr as $key => $value){
  53.   if (is_numeric($key))
  54.   echo "n<ul>n<li>n";
  55.   else
  56.   echo "n<ul>n<li>n" . $key;
  57.   if( ! empty($value)){
  58.     if(is_array($value)){
  59.       show($value);
  60.     }else{
  61.       echo $value;
  62.     }
  63.   }
  64.   echo "n</li>n</ul>n";
  65. }
  66. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top