Re: String /pattern formatting extraction question

From: Date: Mon, 10 Apr 2006 13:22:20 +0000
Subject: Re: String /pattern formatting extraction question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-233665@lists.php.net to get a copy of this message
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)

« previous php.general (#233665) next »