473,326 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Accessing string arrays

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!
Jan 25 '08 #1
7 1293
I'm making a multilanguage app.
so I store the translation in an array...
Using the function system, I can check in a clean mode, if the
variable exist, is empty, or something else, and choose a solution
(i.e. ###string not translated ###
Do you understand what do I mean?
Jan 25 '08 #2

"Giovanni" <bl************@gmail.comwrote in message
news:16**********************************@n20g2000 hsh.googlegroups.com...
I'm making a multilanguage app.
so I store the translation in an array...
Using the function system, I can check in a clean mode, if the
variable exist, is empty, or something else, and choose a solution
(i.e. ###string not translated ###
Do you understand what do I mean?
i understand what you mean, however, you're going about it the wrong way.
Jan 26 '08 #3
Really?Is it not a good idea to store translation data into an array
indexed by string? In this way,if i want to add a language,i only need
to create a new file and translate only the array values. However if
you have any different idea,is appreciated :-)
Jan 26 '08 #4
..oO(Giovanni)
>I'm making a multilanguage app.
so I store the translation in an array...
You could have a look at the gettext extension.

Micha
Jan 26 '08 #5
On 26 Gen, 10:17, Michael Fesser <neti...@gmx.dewrote:
.oO(Giovanni)
I'm making a multilanguage app.
so I store the translation in an array...

You could have a look at the gettext extension.

Micha
mmm....interesting library... I never heard before...but
I should plan some changes in my code...
I could think at this solution in next week,
but now I need find a solution to main problem at top
of this topic, because I've to show a preview in 4 hours :(
Jan 26 '08 #6
How amazing this is. His code worked with 5.2.5 for sure. Obviously none of
the previous repliers cared to test his code, and went ahead with stupid
answers any way.

His code works 100% as long as he calls it the right way, for example
printArrayStr("age"). Obviously he will get notice if he calls
printArrayStr(age).

make sure your answers is relevant, otherwise you are playing pure stupid.
=============================================
"Giovanni" <bl************@gmail.comwrote in message
news:bf**********************************@j20g2000 hsi.googlegroups.com...
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!
Jan 27 '08 #7
Peter Pei wrote:
"Giovanni" <bl************@gmail.comwrote in message
news:bf**********************************@j20g2000 hsi.googlegroups.com...
>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!


How amazing this is. His code worked with 5.2.5 for sure. Obviously
none of the previous repliers cared to test his code, and went ahead
with stupid answers any way.

His code works 100% as long as he calls it the right way, for example
printArrayStr("age"). Obviously he will get notice if he calls
printArrayStr(age).

make sure your answers is relevant, otherwise you are playing pure
stupid.
=============================================
(Top posting fixed)

At least the others didn't top post.

And no, I didn't test his code because he didn't post where the problem
is.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jan 27 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: ree | last post by:
Unlike arrays I am having problems accessing objects placed in a vector I have a vector of objects called Semesters Each Semester has its own vector of Subjects. I am having problems...
6
by: ASPfool | last post by:
Hello everyone, Please help me before I throw my computer out of the window: I'm working on a web application in classic ASP (vbscript), which is making calls to some webservices. The calls...
2
by: C Gillespie | last post by:
Dear All, I have 2 arrays var A1 = new Array(); A1 ="Y2"; var B1 = new Array(); B1 ="Y1"; B1 ="sink";
9
by: sakitah | last post by:
Here is what I have: struct SubList { int BookId; int WFreq; }; struct Listing {
16
by: Don Starr | last post by:
When applied to a string literal, is the sizeof operator supposed to return the size of the string (including nul), or the size of a pointer? For example, assuming a char is 1 byte and a char *...
8
by: Dawn Minnis | last post by:
Hey guys If I have a program (see codeSnippet1) that I compile to be called test.o Then run it as test.o n n 2 3 4 I want the code to be able to strip out the two characters at the start...
2
by: George W. | last post by:
In perl I'm used to using hashtables of arrays and accessing a particular element like this: $HoA{flintstones} Simple as that. How do I access and update values of arrays stored in my hashtable...
3
by: sam | last post by:
hello all, i am currently in the process of planning a piece of software to model polymerisation kinetics, and intend to use python for all the high-level stuff. the number-crunching is...
15
by: bernd | last post by:
Hi folks, a simple question for the experts, I guess. Obviously I am doing something wrong when trying to access an element of an array declared within a structure: #include <stdio.h>...
10
by: Chris | last post by:
Hi, I'd like to be able to access an attribute of a particular Python object as fast as possible from some C code. I wondered if using __slots__ to store the attribute would allow me to do...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.