Question on Arrays.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rkphp
Forum Newbie
Posts: 2
Joined: Tue Jan 27, 2009 3:09 am

Question on Arrays.

Post by rkphp »

Hi everyone,

I'm a learner of PHP.

please help me out on how to define an Associative Array(multidimensional or three dimensional) which will have three values(schemeId, target, destination ).For one schemeId there can be multiple targets and destinations.

And also, In case of database, I'm using the following query to get destination value.

$result = mysql_query("SELECT destination FROM table WHERE shemeId = '$shemeId' AND target = '$alpha'");

now I dont want to use database because of some connection limitations.

so please also tell me, how to get "destination" value from an Associative array.

Thank you very much.
rkphp
Forum Newbie
Posts: 2
Joined: Tue Jan 27, 2009 3:09 am

Re: Question on Arrays.

Post by rkphp »

Thanks guys,

This is what I was looking for and I got it from php-learn-it.

<?php
$employees["employee 1"]["name"] = "Dana";
$employees["employee 1"]["title"] = "Owner";
$employees["employee 1"]["salary"] = "$60,000";

$employees["employee 2"]["name"] = "Matt";
$employees["employee 2"]["title"] = "Manager";
$employees["employee 2"]["salary"] = "$40,000";

$employees["employee 3"]["name"] = "Susan";
$employees["employee 3"]["title"] = "Cashier";
$employees["employee 3"]["salary"] = "$30,000";

echo $employees["employee 2"]["name"].
" is the ".$employees["employee 2"]["title"].
" and he earns ".$employees["employee 2"]["salary"].
" a year.";
?>

Sorry, I should have searched before I post here.

Thanks anyways.
Post Reply