Reputation: 337
In the following If.. else statement, I am trying to see if first, there IS a 4th breadcrumb (URI array 4), and then to see if it is a number..
but both always return true, number, letters, or empty..
can anyone tell me why?
// checks the third breadcrumb contained within the breadcrumbs class to see
// if it is an article. Then uses a recursive function to search the first
// and second breadcrumbs to see if they exist within their respective menu
// arrays. finally, if that validates, then the fourth breadcrumb is checked
// to see if it exists (not empty) AND if it is a number.
else
if (($this->breadcrumbs->getCrumb(3)=='article' &&
$array_helper->recValueReturn($this->breadcrumbs->getCrumb(2),
$this->getNavTwo()) &&
$array_helper->recValueReturn($this->breadcrumbs->getCrumb(1),
$this->getNavOne())) || ($this->breadcrumbs->getCrumb(4)) &&
is_numeric($this->breadcrumbs->getCrumb(4))) {
...
the following always validates to False:
else
if (($this->breadcrumbs->getCrumb(3)=='article'&&
$array_helper->recValueReturn($this->breadcrumbs->getCrumb(2),
$this->getNavTwo()) &&
$array_helper->recValueReturn($this->breadcrumbs->getCrumb(1),
$this->getNavOne())) &&
(array_key_exists($this->breadcrumbs->getCrumb(4),
$this->breadcrumbs->getCrumbs())&&
is_numeric($this->breadcrumbs->getCrumb(4)))) {
...
Upvotes: 0
Views: 240
Reputation: 337
For future reference, and for anyone else reading this..
The problem was solved in the BreadCrumbs class itself.
Previous, breadcrumbs had a private array with the exploded URI values. And I retreived a single url index using:
public function getCrumb($x) { return $this->breadcrumbs[$x] }
But if i modify this getter directly to include an isset:
public function getCrumb($x) {
if (isset($this->breadcrumbs[$x])) {
return $this->breadcrumbs[$x];
} else {
return null;
}
}
and then use the first else..if in the OP.. problem solved. It works.
Upvotes: 1