Re: How to..?
| From: | David Newcomb | Date: | Thu, 13 Jul 2000 13:58:28 +0000 |
| Subject: | Re: How to..? | ||
| References: | 1 2 3 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-1111@lists.php.net to get a copy of this message | ||
Voktech,
Try this as an example, if you have hundreds of variables then you
may find it easier to handle them if they are stored in an associated array.
For example: (Tested and works):
<html><body>
<?
function add_quotes(&$item, $key, $prefix)
{
$item = ereg_replace("(.*)","\"\\1",$item);
}
$tmp[customer] = "bill";
$tmp[text] = "hello";
$tmp[note] = "d-minor";
array_walk($tmp,'add_quotes');
echo "$tmp[customer]<br>\n";
echo "$tmp[text]<br>\n";
echo "$tmp[note]<br>\n";
?>
</body></html>
Does this help?
David.
----- Original Message -----
From: Vojtech Dvorak <vojtech_dvorak@servind.cz>
To: David Newcomb <davidn@vnvi.com>
Sent: Thursday, July 13, 2000 2:18 PM
Subject: Re: [PHP-DB] How to..?
> Yes this works fine too,
> but I have hundreds of these variables ($customer, $text, $report, $note
> etc.) Don't you know how can I quote them all at once?
> Vojtech
>
> >
> > _Will_ do it ;)
> >
> > $customer="\"$customer\"";
> > $text="\"$text\"";
> >
> > David.
> >
> > ----- Original Message -----
> > From: Vojtech Dvorak <vojtech_dvorak@servind.cz>
> > To: <php-db@lists.php.net>
> > Sent: Thursday, July 13, 2000 1:57 PM
> > Subject: [PHP-DB] How to..?
> >
> >
> > > Hi,
> > > I need to add quotes to array of strings.
> > > How can I do that?
> > >
> > > Now, I do every time :
> > >
> > > $customer=' " '.$customer.' " ' ;
> > > $text=' " '.$text.' " ' ;
> > > ... etc.
> > >
> > > Thanks
> > > Vojtech
>