Ask a Question related to PHP Development, Design and Development.
-
Richard Grove - ®ed Eye Media #1
ereg problem
Can any of you kind people tell me what I'm doing wrong?
An example:
$code="<gateway>FooBar</gateway>";
$var="gateway";
I am trying to get the FooBar information from the $code by passing $var and
$code to a regular expression:
$value=eregi("<$var>[a-zA-Z0-9 ]<$var>", $code, $value);
I am trying to make $value contain FooBar.
Regards
Richard Grove
[url]http://www.shopmaker.co.uk[/url] - UK Ecommerce Shop Systems
Richard Grove - ®ed Eye Media Guest
-
ereg
Hi! I'm working with ereg and mails now. Does represent only A-Z, 0-9 or something more? And if yes, ther what? TIA RuBenz -
[PHP] Bug in Ereg?
ow .. this script won't work .. checkboxes like this: <input type=checkbox name="colors" value="on"> or var calling like this: $_POST ... -
Bug in Ereg?
Hi, I have a form with checkboxes that POSTs to a PHP script. What is posted : _POST on _POST on _POST on -
[PHP] ereg problem?
chenqi1@zte.com.cn wrote: It's looking for a \ character or a \ character followed by the letter n anywhere within the string $username. --... -
ereg problem?
who can tell me what's the pattern string mean. if(ereg("",$username)) { /*Do err*/ } -
Richard Grove - ®ed Eye Media #2
Re: ereg problem
and> Can any of you kind people tell me what I'm doing wrong?
>
> An example:
> $code="<gateway>FooBar</gateway>";
> $var="gateway";
>
> I am trying to get the FooBar information from the $code by passing $var> $code to a regular expression:
> $value=eregi("<$var>[a-zA-Z0-9 ]<$var>", $code, $value);
>
> I am trying to make $value contain FooBar.
>
No worries, I've sorted this now:
if(eregi("<$var>(.*)</$var>", $code, $out)) {
$value = $out[1];
}
$value=eregi_replace("<$var>","",$value);
$value=eregi_replace("</$var>","",$value);
> Regards
> Richard Grove
> [url]http://www.shopmaker.co.uk[/url] - UK Ecommerce Shop Systems
Richard Grove - ®ed Eye Media Guest
-
carlos #3
Re: ereg problem
Richard Grove - ®ed Eye Media wrote:
[snip]>>Can any of you kind people tell me what I'm doing wrong?
>>An example:
>> $code="<gateway>FooBar</gateway>";
>> $var="gateway";Why not try a more generic solution e.g.:>
> No worries, I've sorted this now:
>
> if(eregi("<$var>(.*)</$var>", $code, $out)) {
> $value = $out[1];
> }
> $value=eregi_replace("<$var>","",$value);
> $value=eregi_replace("</$var>","",$value);
$code="<gateway>FooBar</gateway>";
preg_match("/<([^>]+)>([^<]+)<.*/",$code,$match);
where $match is an array containing:
0=> FooBar (full patern match)
1=> gateway (first parenthesis)
2=> FooBar (second parenthesis)
now you could do:
$$match[1] = $match2;
wich would resolve in $gateway="FooBar"
HTH
carlos
carlos Guest



Reply With Quote

