note 80235 rejected from function.in-array by danbrown
| From: | danbrown@php.net | Date: | Mon, 08 Jun 2009 21:43:29 +0000 |
| Subject: | note 80235 rejected from function.in-array by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-156509@lists.php.net to get a copy of this message | ||
Note Submitter: lakinekaki at gmail dot com
----
Breadcrumbs navigation for small sites with flat directory structure
Page levels are defined in a multidimensional array. Example array given below
<?php
$array = array(
"contact",
"projects" ,
"projects" => array("architecture",
"architecture" => array("flats","malls")),
"hobbies"
);
function recursive_path($needle,$haystack,$current=''){
if(!is_array($haystack)) return '';
$ret='';
$csad = "$current > <b>$needle</b>";
if(in_array($needle,$haystack))return $csad;
else{
foreach($haystack as $key => $element){
$cposle = "$current > <a href=\"$key.html\">$key</a>";$ret .=
recursive_path($needle,$element,$cposle);
}
}
return $ret;
}
// if current filename is needle, and site structure haystack, than this prints navigation path
echo recursive_path($filename,$array,'You are here: <a
href="./">home</a>');
?>
I tried to do this without redundancies, but after many wasted hours, had to place
'duplicate' values for 'node' keys.
Suggestion for editors:
I was always impressed with this manual, and find it better than any other online programming
resource. I wanted to find out more about the editing process behind it, and I discovered this:
http://news.php.net/php.notes/start/150000
Spending some time there, I saw quite a few useful scripts, and am therefore confused by their
deletions. I can only assume that your level of knowledge is so far beyond of us regular PHP users,
and to you most of scripts are obvious, that to us took a while to write.
Anyhow, here is suggestion: Since you already have almost dozen categories for managing notes,
couldn't you send emails to authors informing them which decision was made. It would be
informative and useful to do that. After all, if 'error' in the editing process is only
3%, it still results in almost 3000 very good notes deleted!
Thanks