You are here: Re: Variable variable name in $_POST ? « PHP Programming Language « IT news, forums, messages
Re: Variable variable name in $_POST ?

Posted by usenet on 12/06/05 02:54

On Mon, 05 Dec 2005 01:19:34 GMT, Oli Filth <catch@olifilth.co.uk> wrote:

>usenet@isotopeREEMOOVEmedia.com said the following on 05/12/2005 00:00:
>>
>> My script receives values for several values :
>> _POST["c1"] = "a"
>> _POST["c2"] = "b"
>> _POST["c3"] = "c"
>> _POST["c4"] = "d"
>>
>> The number of vars posted changes however, so I need to access the $_POST
>> variables using a loop. I figured I could accomplish using one of these
>> assignments, but apparently I'm wrong :
>>
><...SNIP CODE...>
>>
>> Clearly, I'm trying almost anything at this point . . . but I must be missing
>> something obvious, and I can't figure out the narrow Google search to find the
>> answer. Can anyone suggest the solution ?
>
>Try:
>
> $c[$i] = $_POST["c" . $i];
>
>Note how on the left-hand side, I'm using an array. This is nothing to
>do with the problem you're having, but it's generally easier (not to
>mention programatically cleaner) to use an indexable array in PHP rather
>than concatenating strings...

I agree completely -- an array would be the right way to go. But I should have
mentioned in my original that I'm dealing with inherited code. Given my
druthers (and client budget), I'd go back to square one and do things the right
way, but it's not a perfect world . . . <g>

Thanks for your reply.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация