text1 /ptext2 /otext3
Does it always look like that?
text1(whitespace)/ptext2(whitespace)/otext3
The ideea is to extract the texts before and between /o and /p.
$html = "asdäüü ö ö vf /pxtestxx/ostestss";
eregi("^([^/.*]*)", $html, $reg); print_r($reg); //text is in reg[1]
eregi("^(.*)/p([^/.*]*)", $html, $reg); print_r($reg); //text is in reg[2]
eregi("^(.*)/o([^/.*]*)", $html, $reg); print_r($reg); //text is in reg[2]
This example works, but I thought there might be a better way to extract the
texts, with a single ereg or preg_match.
Regards,
Andy.
----- Original Message -----
From: "Barry" <barry@xxxxxxxxxxxxxx>
To: <php-general@xxxxxxxxxxxxx>
Sent: Monday, April 10, 2006 4:22 PM
Subject: Re: String /pattern formatting extraction question
Andy wrote:
Hi to all, I have the following pattern for a string:
text1 /ptext2 /otext3
Does it always look like that?
text1(whitespace)/ptext2(whitespace)/otext3
Then use explode to create an array from it
explode (" ",$stringpattern);
Now, I want to extract the text by "patterns" from this string by the
following rule:
no pattern -> text1 (what is before /o or /p)
/p -> text2 (what is after /p)
/o -> text3 (what is after /o)
Here you can use ereg and foreach
foreach ($stringpattern as $key => $value)
{
$variable = substr_count("/",$value);
if ($variable > 0) / has been found now extract the first two chars
}
Or something like that ~
--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php