On Tue, 6 Mar 2001 15:50, [EMAIL PROTECTED] wrote:
> A problem of inexperience...
>
> I am trying to store an array in mysql. I obtain the array like so--
>
> $partcount = count($Area);
> reset($Area);
> for ($i = 0; $i < $partcount; $i++){
> $key = key($Area);
> $val = $Area[$key];
> $string1 .= $val . "\') or (Area=\'";
> next($Area);
> }
>
> This results, with a bit of coaxing, in an array like this one --
>
> +-----------------------------------------------------+
>
> | Area |
>
> +-----------------------------------------------------+
>
> | (Area='1') or (Area='2') or (Area='3') or (Area='') |
>
> +-----------------------------------------------------+
>
> Everything is falling into place, *except* these last thirteen
> characters --
>
> or (Area='')
>
> And that's what I'd like to eradicate.
>
> Tips, suggestions, especially outright code greatly appreciate.
>
> Thanks,
> Robert
> p.s.-- I have ordered the Friedl book on Regular Expressions. Hoping it
> will enlighten me for the future
My suggestion would be to not create the empty reference in the firast
place :-)
Before starting your loop (but after checking there is something to work
with) use the first element of the arra to create the (Area='1') then you
can loop through the rest of the array, starting with $i = 1 and create
or (Area='$val')
--
David Robley | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/
AusEinet | http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]