79144510

Date: 2024-10-31 11:30:42
Score: 0.5
Natty:
Report link

I reply to this thread of mine with a different issue for the same snippet. After several revisions of the code, it now works as expected, however PHP produces a warning which I would like to resolve.

The part in question is the following:

if (is_shop()) {
        $output = flrt_selected_filter_terms();

        foreach ($output as $value) {
            $x = $value['values'][0];
            $y = get_term_by('slug', $x, $value['e_name']);
            $z = $y->name;

            $new_breadcrumb = new bcn_breadcrumb($z, NULL, array('home'), get_site_url() . '/e-shop/' . $value['slug'] . '-' . $value['values'][0], NULL, true);
            array_splice($breadcrumb_trail->breadcrumbs, -4, 0, array($new_breadcrumb));
        }
    }

It looks as when the bcn object is created, PHP complains:

PHP Warning:  foreach() argument must be of type array|object, bool given
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: fesarlis