473,386 Members | 1,679 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,386 software developers and data experts.

From an Array to a Variable

155 100+
Expand|Select|Wrap|Line Numbers
  1. $lang = array(
  2. 'red'       => 'red',
  3. 'green'     => 'green',
  4. 'brown'         => 'brown'
  5. );
I've tried these:
Expand|Select|Wrap|Line Numbers
  1. $thiscolor = "{$lang['green']}";
  2. $thiscolor = {$lang['green']};
  3. $thiscolor = $lang['green'];
But the variable will not pick up the color. What's wrong?
Thanks
Jun 25 '13 #1
3 1307
Rabbit
12,516 Expert Mod 8TB
Third option works fine for me. You will need to explain what you mean by "will not pick up the color". Because when I output $thiscolor using line 3, I get the expected output string of 'green'.
Jun 25 '13 #2
DavidPr
155 100+
Hmmm, you're right...it is working. I must have inadvertently put an apostrophe or something in the actual code and missed it. Sorry for the trouble, but thanks for your help.
Jun 25 '13 #3
Rabbit
12,516 Expert Mod 8TB
No worries, everyone makes mistakes.
Jun 26 '13 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: MC | last post by:
Hi to all, I would like to use in a XSL stylesheet an array variable which is defined in a Java program. For example, in my program, i defined a tab variable String tab = {"first", "second",...
2
by: Augusto Cesar | last post by:
Hello people. How can I Pass ASP Array variable to Javascript; I´m to trying this: <script language="JavaScript"> var x = new Array(10);
3
by: Don | last post by:
My user control has a combobox with an arraylist attached to it along with custom add and remove methods. The "Add" method is working great. However I don't understand why the "Remove" method...
2
by: satish kumar | last post by:
Hi I'm Satish Kumar, new member of a group. Is it possible to access a server side(VB.NET) array variable from Client Side(Javascript) My VB Page Code: Public x() As Integer ...
5
by: Mercy | last post by:
I guess my C++ is pretty darn rusty. I was just looking over sample C++ code for practice... and I'm kind of confused about this code fragment: int sector2; int i = 3; memset(sector2,...
1
by: Raju5725 | last post by:
Hi All, I struck up with some intrested senario at my application development...hope some body will guide me or sends me some code snippets.... Thanks in advance. Senario is like this..... ...
3
by: Bilbo0a | last post by:
I am trying to save a integer array variable to a file. I am looking for the easier way to do this then going through all items and converting them to a str and then saving them as a text file. ...
4
by: Blackwater | last post by:
There's an old database system called "PICK" - still in use in various forms such as 'OpenQM' - wherein you can SELECT or READ directly into an array variable. For example : "SELECT * FROM...
28
by: Trups | last post by:
HI, I want to dynamically allocate array variable of type LPWSTR. Code looks like this... main() { LPWSTR *wstr; int count = Foo (wstr); for (int i = 0; i < count; i++)
0
by: zacksoniar | last post by:
Hi All, In my application, I need to search a variable which I m searching using regular expression. e.g. "Set Variable1 to 0" This is the string & I know that Set is followed by some variable....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.