Forum Moderators: coopster

Message Too Old, No Replies

split a string into array

split a string into array

         

xbl01234

10:04 pm on Feb 29, 2008 (gmt 0)

10+ Year Member



Hi;
i am trying to split a string into array by regular expression, but it could not work, could anyone help
, please.

my work as following, but it does not work.
i want to break the string into two part, one is "this is the test 1", and another one is "this is testing 2 </object> this is test 3";
$string = "this is the test 1 <object width=\"425\" height=\"355\"> this is testing 2 </object> this is test 3";

$str=split("<object(.?)>",$string);
echo $str[0];
echo "<br>";
echo $str[1];

coopster

10:31 pm on Feb 29, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Search for anything that is not your closing element symbol (the greater than sign) followed by a greater than sign.

$str=split("[[:space:]]*<object[^>]+>[[:space:]]*", $string);

xbl01234

1:59 am on Mar 1, 2008 (gmt 0)

10+ Year Member



Thanks a lot