tags:

views:

40

answers:

2

i got a

$str ="sometxt<br>another<br>moretext<br>evenmoretext<br>";

i'm trying to output the string in one array per line.

kinda like this..

[0] => Array
        (['stuff'] => sometext
        )
[1] => Array
        (['stuff'] => another
        )
[2] => Array
        (['stuff'] => moretext
        )
[3] => Array
        (['stuff'] => evenmoretext
        )

i'm using regex to get the str.. if u need more clarification..i will do. thanks in advance

+3  A: 

Try this:

$arr = explode("<br>", $str);

$resp = array();
foreach ( $arr as $val ){
  $resp[] = array("stuff" => $val);
}

I think this code would solve your dilemma. Tell me if you need any clarification.

David Conde
thanks..dconde.
acrobat
+1  A: 

Try this:

<?php
    $str ="sometxt<br>another<br>moretext<br>evenmoretext<br>";
    $r = array("stuff" => explode("<br>", $str));
    print_r($r);
?>

Array
(
    [stuff] => Array
        (
            [0] => sometxt
            [1] => another
            [2] => moretext
            [3] => evenmoretext
            [4] => 
        )

)
Jet
I think that the endgame is not just the output, and beside that, you'd need to add a <pre> tag before and after the print_r to get the response you placed ;) Nice one anyways!
David Conde
I use this:Header('Content-Type:text/Plain')
Jet
thanks man..worked just fine.
acrobat