You are here: Re: Accessing string arrays « PHP Programming Language « IT news, forums, messages
Re: Accessing string arrays

Posted by Steve on 09/28/50 12:01

"Jerry Stuckle" <jstucklex@attglobal.net> wrote in message
news:Iqydnfz_u548BgHanZ2dnUVZ_gadnZ2d@comcast.com...
> Giovanni wrote:
>> Hi! I've an array of string like this:
>>
>> $arraystring["name"]="John";
>> $arraystring["age"]="50";
>> $arraystring["work"]="teacher";
>>
>> $arraystring is global variable.
>>
>> I'm trying to code a function that get a string as parameter and print
>> the relative arraystring's value.
>>
>> function printArrayStr($key)
>> {
>> global $arraystring;
>> echo $arraystring["$key"];
>> }
>>
>> What do I wrong?! :(
>>
>> tnx, people!
>>
>
> First of all, don't use globals. If you want to pass it to the function,
> pass it to the function. As a global, $arraystring could be changed
> anywhere, and you'll have a hard time figuring out what the problem is.
>
> But are you sure this is *exactly* like you have it in your code? For one
> thing, you shouldn't have quotes around $key as the index.
>
> But you never told us what your problem is, so it's impossible to tell you
> what the cause is. For instance, Enable all error reporting and display
> errors - do you get any error messages? What's actually in $arraystring
> and $key in the function?
>
> And finally - I agree - this is probably one of the $*worst* ways to
> handle multiple languages.

thank you very much, jerry. we finally agree on something. :)

 

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

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