vendredi 16 octobre 2020

PHP if and statement returning no results in foreach loop [closed]

I am running a foreach loop and want to show results that match both $collection->type == 'personal' and $collection->owner == $user['userName'], but I am getting 0 results, but I know they are there.

I can echo both $user['userName'] and $collection-owner just fine so I cannot figure out why I cannot get results when I filter by them. Here is my code:

foreach ($collections as $collection){
  if ($collection->type == 'personal' && $collection->owner == $user['userName']){
    echo '<li>'.$collection->name.' - '.$collection->owner.' - '.$user['userName'].'</li>';
  }
}

I have even tried directly entering a username in the statement $collection->owner == 'example' to debug and that's not working either.

Aucun commentaire:

Enregistrer un commentaire