welp im up to the part were i get to learn arrrays in php.. and its almost the same as in c .. but yet.. i dont get it (ya its true i know some c but arrays is diffrent in someways) can anyone please explain to me by showing me an example of arrays on how to deal with them..
for example can you show me using some linux commands like..
ls , cat, pwd, etc.. im tring to understand how arrays work on php... thanx
php/arrayz
Moderators: egami, macek, gesf
Computer/Programm rox.. (php, c/c++ will take over soon muhahah
- Joan Garnet
- Moderator
- Posts: 387
- Joined: Sat Aug 03, 2002 2:56 am
- Location: Mars
- Contact:
Code: Select all
/////////////////////////////////////////////////////////////
//simple array///////////////////////////////////////////////
/////////////////////////////////////////////////////////////
$simple_array = array('one','two','three');
echo "<pre>";//to view the shape with a better format
print_r ($simple_array);//will output this simple array
echo "</pre><br>";
/////////////////////////////////////////////////////////////
//a bidimensional array//////////////////////////////////////
/////////////////////////////////////////////////////////////
$my_array = array( 'colors' => 'red',
'fruits' => 'apple',
'hair' => 'curly'
);
echo "<pre>";
print_r ($my_array);
echo "</pre><p>";
/////////////////////////////////////////////////////////////
//let's get some values//////////////////////////////////////
/////////////////////////////////////////////////////////////
echo $my_array["colors"]."<br>";
echo $my_array["fruits"]."<br>";
echo $my_array["hair"]."<p>";
Anyway...
http://www.phpfreaks.com/phpmanual/page ... array.html
This a complete explanation
;)
- WiZARD
- Moderator
- Posts: 1240
- Joined: Thu Jun 20, 2002 10:14 pm
- Location: Ukraine, Crimea, Simferopol
- Contact:
From manual ls:
Code: Select all
function GetDirArray($sPath)
{
//Load Directory Into Array
$handle=opendir($sPath);
while ($file = readdir($handle))
{
$retVal[count($retVal)] = $file;
}
//Clean up and sort
closedir($handle);
sort($retVal);
//return $retVal;
while (list($key, $val) = each($retVal))
{
if ($val != "." && $val != "..")
{
$path = str_replace("//","/",$sPath.$val);
echo "$path
";
if (is_dir($sPath.$val))
{
GetDirArray($sPath.$val."/");
}
}
}
}
"Sex,Drugs and Rock&Roll " replaced at "Sucks,Bugs and Plug&Play";

