PHP string to assay: HELP

Discussion in 'PHP' started by KingCobra, Sep 20, 2010.

  1. #1
    I have a string
    $string = "my text line 01<br>my text line 02<br>my text line 03";
    PHP:
    I want to make another array like string and put on $array variable that will look like

    	$array = array(
    		array('my text line 01'), 
    		array('my text line 02),
    		array('my text line 03)
    	);
    PHP:
    PLEASE HELP ME
     
    KingCobra, Sep 20, 2010 IP
  2. ivan.kristianto

    ivan.kristianto Active Member

    Messages:
    136
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #2
    You can use explode function:
    here is the example:

    $array = explode("<br>", $string);
    PHP:
    it will make your string to array.
    Then you process the array[index] to another array as you like.
     
    ivan.kristianto, Sep 20, 2010 IP
  3. sunlcik

    sunlcik Peon

    Messages:
    39
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    <?php
    $string = "my text line 01<br>my text line 02<br>my text line 03";
    $arr    = split("<br>",$string);
    $arr1   = explode("<br>",$string);
    $arr2   = preg_split('|<br>|si',$string);
    
    PHP:
    There are too many methods...pls check these code.
     
    sunlcik, Sep 20, 2010 IP
  4. ashishkg

    ashishkg Active Member

    Messages:
    233
    Likes Received:
    8
    Best Answers:
    3
    Trophy Points:
    68
    #4
    yes, there is many way to do this and this is most simplest way
    $arr = explode("<br>", $string);
     
    ashishkg, Sep 21, 2010 IP