Page 1 of 1

Question on Arrays.

Posted: Tue Jan 27, 2009 3:23 am
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.

Re: Question on Arrays.

Posted: Tue Jan 27, 2009 5:55 am
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.