Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1105583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:39:22+00:00 2026-05-17T01:39:22+00:00

I have absolutely no idea what I’m doing wrong right now. I think I’m

  • 0

I have absolutely no idea what I’m doing wrong right now. I think I’m mentally exhausted, because I’m utterly clueless. Here’s the code I’m using:

if(empty($this->updates) || !is_array($this->updates))
    return null;

foreach($this->updates as $update)

This is failing. HOWEVER, if I do a print_r($this->updates) before the foreach (and after), it works perfectly fine. Why is it that when I try to use it in a foreach it pretends the array doesn’t exist?

Sample print_r($this->updates):

Array
(
    [0] = Array
    (
        [id] => 1 
        [name] => test
    ) 
    [1] = Array
    (
       [id] => 2 
       [name] => rawr
    )
)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T01:39:22+00:00Added an answer on May 17, 2026 at 1:39 am

    Since you don’t tell what $this->updates is, I can simply assume it’s not an array. Here, you have two options :

    1- Replace empty() with !is_array() to check if $this->updates is valid or not. If it’s empty, it doesn’t matter, the foreach will simply do nothing…

    if(!is_array($this->updates))
        return null;
    
    foreach($this->updates as $update)
    

    Or if the foreach is not the only processing you do :

    if(empty($this->updates) || !in_array($this->updates))
        return null;
    
    foreach($this->updates as $update)
    

    2- Force $this->updates to be an array

    if(empty($this->updates))
        return null;
    
    foreach((array) $this->updates as $update)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

let me first off noting that I have absolutely no idea what I'm doing
I have absolutely no idea about version control. Only that it can be very
I have absolutely no idea how to do this, so I'm just gonna go
I have absolutely no idea why this is happening but the following code seems
I know that the title is very subtle but I have absolutely no idea
I'm very new to Perl, and I have absolutely no idea how to approach
this morning I came across this code, and I have absolutely no idea what
I am absolutely terrible at logging my hours. So my idea is to have
I have an absolutely positioned div containing several children, one of which is a
I'm working on a website that requires a flash mp3 player. I have absolutely

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.