PHP Explode() - Displaying results help needed

Discussion in 'PHP' started by pictureboarduk, Sep 28, 2009.

  1. #1
    Hi !

    I'm using the PHP Explode() function to seperate some strings.

    For example, if I explode the following string:

    and use the 's' as the separator, I get the following output in a webpage:

    I was wondering how I could instead format the results so that they display like this in a webpage:

    I've tried placing the <br /> tag in my code, but have either missed where it should go, or this is not the right way in the first place.

    This is the function call:



    Thanks will go to anyone who can help me with this!

    Thanks! :)
     
    pictureboarduk, Sep 28, 2009 IP
  2. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #2
    Place the print_r inside <pre></pre> tags.

    
    echo '<pre>';
    print_r($array);
    echo '</pre>';
    
    Code (markup):
     
    ThePHPMaster, Sep 28, 2009 IP
    pictureboarduk likes this.
  3. caprichoso

    caprichoso Well-Known Member

    Messages:
    433
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    110
    #3
    You have to learn a lot if you are unable to solve this. Read the first part of the manual at www.php.net and practice a lot:

    
    <?php
    if(isset($_POST['submit']))
    {
    $data = explode($_POST['seperator'],$_POST['string']);
    foreach($data as $k => $v) {
      echo "[$k] => $v <br />";
    }
    ?> 
    
    PHP:
     
    caprichoso, Sep 28, 2009 IP