Web Hosting Talk







View Full Version : PHP Arrays


Lippy
11-17-2002, 03:06 AM
I looked at the manual on the php site about it but didn't quite understand what it meant. If some one clould explain it a bit clearer for me as to how to set value in an array and such. Thanks

Bulldog
11-17-2002, 03:22 AM
Edit: Missed the last part --


<?php
$name[] = "Bob";
$name[] = "John";
?>

or you could also set it this way

<?php
$name = array ("Bob","John");
?>


An array is nothing more than another way to store and display data.

Lippy
11-17-2002, 03:31 AM
now in access it for example if I wanted to compare the value in the array to another value. for example in psuedo code.


<?php
$name[]
//declaring $name for future use, not sure if possible in php
if (data == $name[]) //data represents another value
{
//do something
}
else
{
//do something else
}

jtan
11-17-2002, 03:49 AM
$A[0]="hello";
$A[1]="<br>";
$A[2]="world";

for($counter=0;$counter<3;$counter++)
{
echo "$A[$counter]";
}

that would give a result of:
hello
world

Lippy
11-17-2002, 03:51 AM
thanks both of you, its very similar to java(if not the same) just wanted to make sure before I started screwing with a friends code to make something to work.