Arrays in PHP fall into two categories-- indexed and associative. An indexed array is where each array element is denoted by a number (a subscript). They are a bit like arrays in C.
The other kind of array is an associative array. In these, each element is denoted by another string value. A bit like a hash in Perl. Example: (take note of the beginning of the script)
[tt]<?php
$dictionary['mouth'] = 'the opening through which an animal takes in food';
$dictionary['free'] = 'enjoying personal rights or liberty';
$dictionary['rush'] = 'to move, act, or progress with speed';
?>
<html><head><title>Dictionary</title></head>
<body>
<h1>A Little Dictionary</h1>
<h3>Look up a word:</h3>
<form method="GET" action="dictionary.php">
<input type=text name="word">
<input type=submit>
</form>
<?php
if (isset($_GET('word')) {
if (isset($dictionary($_GET('word')) {
?>
<HR>
<H2><?php echo $_GET('word') ?></H2>
<P><?php echo $dictionary($_GET('word')) ?></P>
<?php
} else {
?>
<HR>
<P>Error: The word '<?php echo $_GET('word')?>' is not in our dictionary.</P>
<?php
} else {
?>
<P>Please type a word into the box, and click Submit.</P>
<?php
} ?>
<HR>
<SMALL><I>Powered by Tek-Tips Forums</I></SMALL>
</body>
</html>[/tt]
Maybe i didnt ask the right question. I need to take the results of a mysql search store the returned values in an array then pass that array to another program.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.