Re: Getting Results from function; snickers != buttery !
| From: | Kevin Leavell | Date: | Thu, 16 Nov 2000 06:00:24 +0000 |
| Subject: | Re: Getting Results from function; snickers != buttery ! | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-25621@lists.php.net to get a copy of this message | ||
Mark's code helped but I seem to be one step away.
<?
$string='<input type="hidden" name="snickers" value="good">
<input type="hidden" name="mars bar" value="bad">
<input type="hidden" name="peppermint patty" value="ugly">
<input type="hidden" name="butterfinger" value="buttery">';
$key=ereg_replace('<input type="hidden"
name="([^"]+)".*','\\1',$string);
$value=ereg_replace('.*value="([^"]+)">','\\1',$string);
$$key=$value;
print $snickers;
This code makes snickers = buttery which we know isn't true. snickers needs
to equal good.
How do I step through $string to create individual variable with the right
value.
TIA
Kevin
----- Original Message -----
From: Mark Maggelet <maggelet@mminternet.com>
To: <k@bigsky.net>; <php-general@lists.php.net>
Sent: Wednesday, November 15, 2000 6:23 PM
Subject: Re: [PHP] Getting Results from function
> On Wed, 15 Nov 2000 16:50:16 -0700, Kevin Leavell (k@bigsky.net)
> wrote:
> >I am using the Snoopy class to submit to a form and receive the
> >results. I
> >am then parsing the hidden form fields
> ><input type="hidden" name="butterfinger" value="one">
> ><input type="hidden" name="snickers" value="good">
> >down to
> >butterfinger="one";
> >snickers="good";
> >
> >Here is the call to the function:
> >if ($go){
> > $string=_stripform($snoopy->results);
> >//do some additional parsing here
> > $string2= ereg_replace ("<input type=\"hidden\" name=\"",
> > " $",
> >$string);
> > $string3= ereg_replace ("\" value", "", $string2);
> > $string4= ereg_replace (">", ";\r\n", $string3);
> > echo $string4;}
> >
> >when I echo $string4, I get the correct results but they aren't
> >parsed by
> >php. The variables list on the page as a text. I need the
> >variables and I
> >don't understand how I can access the variables as in:
> >print $butterfinger;
>
> I'm not sure I understand, but try something like this:
> <?
> $string='<input type="hidden" name="snickers"
> value="good">';
> $key=ereg_replace('<input type="hidden"
> name="([^"]+)".*','\\1',$string);
> $value=ereg_replace('.*value="([^"]+)">','\\1',$string);
> $$key=$value;
> print $snickers;
> ?>
>
> - Mark
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>