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

Setting condidtions for an input box
Hi all,

I would like to set a condition in a txt box that says the number a user enters has t

Developing Ajax-enabled ASP.Net applications for the iPhone
I would like to develop Ajax web applications using Visual Studio that are optimized for the iPhone.

please help me in this update statment
hi every one

if I have table and this data in it

id name
10

php mysql script to find record
Hi,

Currently I have a simple table with 4 columns. A, B, C, D

If I want to find all

PHP header help!
Hi all I am trying to get this php page to refresh every 5 seconds on my phone which is an aastra 48

Create or replace package is ending ORA-21700
Database 9.2.0., patch 8 (9.2.0.8.0).
I trying run
create or replace package ....etc.

start new row of pictures
on my site www.budstreasureauctions.com there is a featured auctions box that users will pay to get

php redirecting
i wont open a new thread but i have a question about redirecting....
i wonder why my code doesnt

Big O & time complexity ???
can you help me how to calculate the Big O & time complexity for any algorithm and c++ program pleas

frames get header location..
i have two frames, one top, one bottom. how do i do a form on the bottom frame that gives me the ur

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