Implode

Discussion in 'PHP' started by Silver89, Sep 25, 2011.

  1. #1
    I'm trying to join an array so it appears as a list with:

    
    $method = strip_tags(mysql_real_escape_string($_POST[forminput]));
    $method = implode("</li><li>", $method);
    $method = "<li>".$method."</li>";
    
    PHP:
    but it's not liking this approach and tells me parameter 1 of implode is an array where as it should be a string??
     
    Silver89, Sep 25, 2011 IP
  2. Minimal ™

    Minimal ™ Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Works just fine for me. Are you sure the error came from the lines you have posted ?
     
    Minimal ™, Sep 25, 2011 IP
  3. JohnnySchultz

    JohnnySchultz Peon

    Messages:
    277
    Likes Received:
    4
    Best Answers:
    7
    Trophy Points:
    0
    #3
    JohnnySchultz, Sep 26, 2011 IP
  4. mfscripts

    mfscripts Banned

    Messages:
    319
    Likes Received:
    4
    Best Answers:
    8
    Trophy Points:
    90
    Digital Goods:
    3
    #4
    I think you mean 'variable type of array'... :)
     
    mfscripts, Sep 26, 2011 IP
  5. Silver89

    Silver89 Notable Member

    Messages:
    2,243
    Likes Received:
    72
    Best Answers:
    0
    Trophy Points:
    205
    #5
    Well it is to be used in a query but that's a few lines down, I prefer not to share my queries for security :)

    The problem was the functions being in the wrong order, if you do the mysql_real_escape_string last on the completed string then it works fine!

    
    $ingrediants = "<li>".mysql_real_escape_string(strip_tags(implode("</li><li>", $_POST[ingrediants]), "<li>"))."</li>";
    
    PHP:
     
    Silver89, Sep 26, 2011 IP