Display Array Contents

echo '<pre>';
print_r ($_POST);
echo '</pre>';


  1. User Avatar
    Mark Cole
    Permalink to comment#

    Seriously? This is terrible lol.

  2. User Avatar
    Permalink to comment#

    lmao!!!!!!!!!!!!!!!!!!!!!!!!! this is funny

  3. User Avatar
    Permalink to comment#


    so, an attempt to correct this users coding..


    $array[0] = "CSS";
    $array[1] = "HTML";
    $array[2] = "PHP";
    $array[3] = "JavaScript";
    echo '';
    print_r ($array);
    echo '';


        [0] => CSS
        [1] => HTML
        [2] => PHP
        [3] => JavaScript
  4. User Avatar
    Permalink to comment#

    haha this is too basic for a snippet

  5. User Avatar
    Bill Brown
    Permalink to comment#

    Or this:

    echo '<pre>',print_r($array,1),'<pre>';

    • User Avatar

      For beginners:

      The reason we use a comma instead of a period/dot between the ‘pre’ and the print_r() is because print_r() does an echo from itself.

      If you would use a dot instead then it PHP will echo print_r() and AFTER that a pre and a /pre.


      As we can read here:

      print_r() takes a second argument to return instead of echo:

      echo '<pre>' . print_r($array,true) . '</pre>';

      Note: We use dots instead of comma’s, and give print_r() an extra ‘true’ (= return).

      Not as short, but just to explain to beginners how the spoon fits in the fork xD

  6. User Avatar
    Permalink to comment#

    I’m sorry to say that not everybody is experienced who come here.It is a wonderful resource for the all levels of coder. Keep it up Chris.. Thanks

  7. User Avatar
    Permalink to comment#

    Gringer. I agree with you. Thanks.

  8. User Avatar
    Permalink to comment#

    You can as well use the foreach statement to get the content of an array out.. you use that when you need to perform something to every single one of the array element…

    $someArr = array(1,2,3,4,5…)
    foreach ($someArr as $newVar){
    //whatever you need to do to array members
    echo $newVar;

  9. User Avatar
    Permalink to comment#

    Hi iam trying to use this code with an animated login and register form. the form works fine. as soon as i put the php err code the whole form looses its css and freezes. please check code here http://codepen.io/anon/pen/PZKBpW

    thanks your help will be appreciated

  10. User Avatar
    Permalink to comment#

    hi sorted.
    check the solution here http://codepen.io/anon/pen/XXemJB

  11. User Avatar
    Permalink to comment#

    there is one problem though . i want my err mesg with a border. if i show border on css then the form displays the border of the div even if there is no err. basically i want the div there as empty and if the submit has errors then the err show and outline with a border. any help there pleae

Leave a Comment

Posting Code!

You may write comments in Markdown. This makes code easy to post, as you can write inline code like `<div>this</div>` or multiline blocks of code in triple backtick fences (```) with double new lines before and after.

Code of Conduct

Absolutely anyone is welcome to submit a comment here. But not all comments will be posted. Think of it like writing a letter to the editor. All submitted comments will be read, but not all published. Published comments will be on-topic, helpful, and further the discussion or debate.

Want to tell us something privately?

Feel free to use our contact form. That's a great place to let us know about typos or anything off-topic.