|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
how can I print certain item(s) of an array
Hello,
I am trying to read the directory, where there are pages, into an array and print the files as links. But I do not want all the files to be printed. I use this code function directory($result) { $handle=opendir("$result"); $count = 0; # Gather the files, and put them in a array while( $file = readdir( $handle) ) { $file_array[] = $file; } foreach( $file_array as $file ) { if( $file == ".." || $file == "." ) { continue; } if( !eregi( ".htm$", $file ) ) { continue; } $file=eregi_replace(".htm$","",$file); # Display the file with a link echo"$file"; } echo"</blockquote>"; #close thedirectory you used closedir($handle); return $result; } $son=directory(ingilizcedersleri); echo "$son"; This function print all files but I want print, let's say, only first and fourth element of the array. Thanks in advance Mk echo $son[0] echo $son[3] |
|
#2
|
|||
|
|||
|
RE: how can I print certain item(s) of an array
echo $array[0];
echo $array[3]; that should print out the 1st and 4th element |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > how can I print certain item(s) of an array |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|