xbl1 Posted February 29, 2008 Share Posted February 29, 2008 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]; Link to comment Share on other sites More sharing options...
Synook Posted March 1, 2008 Share Posted March 1, 2008 Try $str=split("<object(.*?)>",$string); Link to comment Share on other sites More sharing options...
jhecht Posted March 1, 2008 Share Posted March 1, 2008 Can i ask as to WHY you want to break it up like that? Link to comment Share on other sites More sharing options...
xbl1 Posted March 1, 2008 Author Share Posted March 1, 2008 Try$str=split("<object(.*?)>",$string); it doesn't work, but i found the solution already, i do as following:preg_split("/<object[^>]*>/", $string); Link to comment Share on other sites More sharing options...
xbl1 Posted March 1, 2008 Author Share Posted March 1, 2008 Can i ask as to WHY you want to break it up like that?well, i just do want to get some values from a string. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.