...

View Full Version : split a string into array



kamkam
02-29-2008, 09:59 PM
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];

Scrumpy.Gums
02-29-2008, 11:13 PM
I think preg_split (http://php.net/preg_split) should do what you want.

kamkam
03-01-2008, 01:41 AM
Thanks a lot.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum