Note that there are some explanatory texts on larger screens.

plurals
  1. POTrying to make multilevel dynamic menu in PHP using RecursiveIteratorIterator
    primarykey
    data
    text
    <p>I am trying to code a multilevel page menu navigation but not working correcly and i doubt that it is something to do with the line RecursiveIteratorIterator, any help would be appreciated .I was thinking in the solution that way but maybe I went far. Thanks for the help. Here is my code :</p> <pre><code>&lt;ul id="nav"&gt; &lt;?php //searchWebsitePagesPath("blog.php"); ?&gt; &lt;li&gt;&lt;a href="&lt;?php echo searchWebsitePagesPath('index.php'); ?&gt;"&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;!-- &lt;li&gt;&lt;a href="index.php" id="here"&gt;Home&lt;/a&gt;&lt;/li&gt; --&gt; &lt;li&gt;&lt;a href="&lt;?php echo searchWebsitePagesPath('blog.php'); ?&gt;"&gt;Journal&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="&lt;?php echo searchWebsitePagesPath('gallery.php'); ?&gt;"&gt;Gallery&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="&lt;?php echo searchWebsitePagesPath('files_upload.php'); ?&gt;"&gt;Upload&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="&lt;?php echo searchWebsitePagesPath('contact.php'); ?&gt;"&gt;contact&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="&lt;?php echo searchWebsitePagesPath('register.php'); ?&gt;"&gt;Register&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;?php function searchWebsitePagesPath($pageName){ // echo ("$pageName"); // $files = ""; $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator('.')); $my_path=""; $myArray=""; $pathReplace=""; $finalPathReplace=""; foreach ($files as $file) { if($file-&gt;getFilename() === $pageName ){ $pathReplace=str_replace (str_replace('/','\\',$_SERVER['DOCUMENT_ROOT']),'',$file-&gt;getRealPath()); $finalPathReplace = $pathReplace ; // echo $finalPathReplace; $myArray=explode("\\",$pathReplace) ; $count= count($myArray); $reverted = new ArrayIterator(array_reverse($myArray)); $server_path="" ; for($i=1;$i&lt;$count;$i=$i+1 ) { $server_path =$server_path."../"; } $my_path=$server_path.$reverted[$count-1]; } } $my_path="\"$my_path\"" ; $files = ""; $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator("$my_path")); foreach ($files as $file) { if($file-&gt;getFilename() === $pageName ){ $pathReplace=str_replace (str_replace('/','\\',$_SERVER['DOCUMENT_ROOT']),'',$file-&gt;getRealPath()); $finalPathReplace ='/'.str_replace ('\\','/',$pathReplace) ; return $finalPathReplace; } } } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload