Hi everyone,
I need to split a string into an array according to a given conditon.Basically its like this,
If we consider the string variable as $str , it has a value as,
$str="<b>this is a test to fetch the data out of a <status>string</status> variable</b>";
the condition is that i want to break this string using <status> and </status> tags.
So when it splits the array element $arr[0] will have the string value bfore the <status> (<status> also included in that) and the $arr[1] wll have the value as "string" (According to my example) and the $arr[2] will have the rest(With </status>)
I can do this with the help of explode function.. but i wants to know is that is there any regular expression function to do this... i tryed eregi() function but didn`t got any results, the code is given below,
$content="<b>this is a test to fetch the data out of a <status>string</status> variable</b>";
eregi('<status>*</status>',$content,$newContent);
while(list($key,$value)=each($newContent))
{
print $key." = ".$value."<br>";
}
anyone has any idea!!!
thanx in advance,
regards,
niroshan