Re: how can I add a variable to this sample
| From: | Philip Hallstrom | Date: | Thu, 03 Jan 2002 23:27:16 +0000 |
| Subject: | Re: how can I add a variable to this sample | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-79389@lists.php.net to get a copy of this message | ||
$service_type_insert = $x[${key}service_type];
should work.
On Thu, 3 Jan 2002, Tom Beidler wrote:
> I have a large form that I would like to edit a number of records. I'm
> putting all of the fields into one array and then I would like to pull the
> fields independently from a loop.
>
>
> Here's part of the loop
>
> foreach ($z as $key => $value) {
> $service_type_insert = $x['$keyservice_type'];
>
> What I'm looking for is for the $key variable to be replaced with the record
> id, which is what $key is. So the second line should look like;
>
> $service_type_insert = $x['629service_type'];
>
> I've tried a number of variations, i.e.;
>
> $service_type_insert = $x[$keyservice_type];
>
> $service_type_insert = $x['\$keyservice_type'];
>
> $service_type_insert = $x["$keyservice_type"];
>
> Is there a way that I can format it correctly?
>
> Thanks,
> Tom
>
> --
> 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
>