How To Display Array Elements With Loop Get Show Array Values In PHP Tutorial
RegisterLogin
Webune Forums » Tutorial and Guides » How To Display Array Elements With Loop Get Show Array Values In PHP Tutorial
How To Display Array Elements With Loop Get Show Array Values In PHP Tutorial
Post Description: How To Display Array Elements With Loop Get Show Array Values In PHP Tutorial
Tags: How, To, Display, Array, Elements, With, Loop, Get, Show, Array, Values, In, PHP, Tutorial
This Post Was Posted On Feb 29, 2008 By web hosting #495
Post Description: How To Display Array Elements With Loop Get Show Array Values In PHP Tutorial
Tags: How, To, Display, Array, Elements, With, Loop, Get, Show, Array, Values, In, PHP, Tutorial
This Post Was Posted On Feb 29, 2008 By web hosting #495
How To Display Array Elements With Loop Get Show Array Values In PHP Tutorial by web hosting
/var/www/html/home/web/mydomain/root
and i want to only capture mydomain out of all this and i want to break this directory path into an array so var would be one element of the array. with php i can do this
first i will creat a string with the value of my script path:
$path = getenv('SCRIPT_FILENAME')
next i want to make $path into an array:
$path = explode("/", $path );
now i have created an array and now its time to display each element into their individual value, i will use a for loop for this:
for($i =0; $i < count($words); $i++) {
echo $words[$i]."<br>";
}
and now it will display each element using the loop
if you want to try it yourself copy and paste the code below into your text editor and save it as array.php and upload to your php website and see it for yourself.
PHPCODE:
<h1>DISPLAY ARRAY ELEMENTS TUTORIAL </h1>
<strong>Tutoral by <a href="http://www.webune.com">www.webune.com</a></strong><br><br>
<?
## THIS TUTORIAL CREATED BY WWW.WEBUNE.COM LICENSED THROUGH WWW.WALLPAPERAMA.COM
$dir_fs_www_root = getenv('SCRIPT_FILENAME');
echo "<strong>Script Path: ".$dir_fs_www_root."</strong><br><br>";
echo "<strong>Array Elements:</strong><br><br>";
$words= explode("/", $dir_fs_www_root );
for($i =0; $i < count($words); $i++) {
echo "<strong>$words[$i]</strong> = ";
echo $words[$i]."<br>";
}
?>
<br><br>
<div align="center">
<a href="http://www.webune.com">
<img src="http://www.webune.com/images/headers/default_logo.jpg" border="0">
</a></div>
<strong>Tutoral by <a href="http://www.webune.com">www.webune.com</a></strong><br><br>
<?
## THIS TUTORIAL CREATED BY WWW.WEBUNE.COM LICENSED THROUGH WWW.WALLPAPERAMA.COM
$dir_fs_www_root = getenv('SCRIPT_FILENAME');
echo "<strong>Script Path: ".$dir_fs_www_root."</strong><br><br>";
echo "<strong>Array Elements:</strong><br><br>";
$words= explode("/", $dir_fs_www_root );
for($i =0; $i < count($words); $i++) {
echo "<strong>$words[$i]</strong> = ";
echo $words[$i]."<br>";
}
?>
<br><br>
<div align="center">
<a href="http://www.webune.com">
<img src="http://www.webune.com/images/headers/default_logo.jpg" border="0">
</a></div>
Leave Your Comments
Related Pages: [Add Your Website]
Post New Topic
jhmkj
#4959 1
how to do the reverse?
Apr 03, 2011 Reply Report abuse
tech support
#623 2
take a look at this tutorial. it helped me alot
how-to-index-arrays-and-show-all-the-elements-and-values-of-array
how-to-index-arrays-and-show-all-the-elements-and-values-of-array
Feb 24, 2008 Reply Report abuse
©2012 Webune Forums - Thu Dec 13, 2012 6:58 pm
Powered by: Webune Forums V3
Powered by: Webune Forums V3