hakhaimo Posted August 20, 2008 Share Posted August 20, 2008 Hi! I am new here and I am also new to php since I am used to java(JSP) below is my problem This is my code: <?php $s = '<p>bleh blah</p><p style="one">one two three</p>'; $htmlbits = preg_split('/(<p( style="[-:a-z0-9 ]+")?>|<\/p>)/i', $s, -1, PREG_SPLIT_DELIM_CAPTURE); //print_r($htmlbits); $nElements = count($htmlbits); $htmlArrays = array(); for($x=0; $x<$nElements; $x++) { echo "Number: ".$x." - ".$htmlbits[$x]."<br>"; } ?> My expected output should be: Number: 0 - Number: 1 - <p> Number: 2 - bleh blah Number: 3 - </p> Number: 4 - Number: 5 - <p style="one"> Number: 6 - style="one" Number: 7 - one two three Number: 8 - </p> Number: 9 - My actual output is: Number: 0 - bleh blah Number: 1 - Number: 2 - Number: 3 - Number: 4 - style="one" Number: 5 - one two three Number: 6 - Number: 7 - THANK YOU VERY MUCH!!!!!!!! I really need this badly! Link to comment https://forums.phpfreaks.com/topic/120598-how-to-displaymanipulate-arrays-in-php-from-preg_split/ Share on other sites More sharing options...
effigy Posted August 20, 2008 Share Posted August 20, 2008 They're HTML tags so they're not "shown." View the source Link to comment https://forums.phpfreaks.com/topic/120598-how-to-displaymanipulate-arrays-in-php-from-preg_split/#findComment-621460 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.