|
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]
|