How can use this array as a key?


Posted on 16th Feb 2014 07:03 pm by admin

Say I have this array for example:


print_r($array);

Prints:
Code: [Select]Array
(
[0] => Array
(

[status] => 0

)

[1] => Array
(
[status] => 1

)

[1] => Array
(
[status] => 0

)
)

Now I have another array:

$color_array = array('0'=>'nocolor','1'=>'green');

How I can do the logic of this?


foreach($array as $tmp){

// Say status holds "1" in this case so it translate to
//$color_array[1]; = green
echo "{$color_array[$tmp['status']]}";

}


Obviously the above generate Illegal offset type. So I cant do that.

No comments posted yet

Your Answer:

Login to answer
221 Like 17 Dislike
Previous forums Next forums
Other forums

mysql select query problem
how can i select multiple fields from multiple table in one query like

i have table name t1 a

what business processes?
Hi,

A general question. What business processes (like OTC - Order to Cach, P2P, R2R etc)

BI in Upstream Production operations
Appreciate if you can assist in the following areas:
1) Examples of life before and after BI i

How to use php and sql to check if values match the ones in a table (for logins)
How would I code it that the script takes two variables that are passed to it (UserID and PIN), and

Mail Script Problems
I have created a PHP mail script. I am having a problem though. In $body i am trying to put two va

Query failed issue with php script but works fine in mssql manager!
hi i have the script below which copies data from one table to another but will only insert new data

please help me... my password gets encrypted but not able to get in database
hai guys,
please help me... in the following function my password gets encrypted but no

Not connecting to DB using ruby, error:env.c:257:in oci8lib.so: ORA-12154:
Hi All,

I am trying to connect to the database server from the client server using ruby and f

PayPal Redirect Issue
When I have my paypal button set so that is redirects to http://empiremarketing.ca/order.php,it work

Using loop to count number of entries
I'm writing a program that must ask user to type in numbers. After each entry, the program has to re

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash