Jump to content

Recommended Posts

Hi

 

I am having some problems accessing some Zend_Date objects in an Array. I have a function to generate table rows. It receives an object that contains an array of data to put in the table. See below:

CODE: SELECT ALL

protected function getData($component){

      $data = "";

      foreach($component->getData() as $dataItem){

        $data .= "  <tr class='data'>";

       

        for($i = 0 ; $i < $component->getMaxColumns(); $i++){

            $data .= "    <td>";

            if(array_key_exists($i, $dataItem)){

              $date = $dataItem[$i];

              $data .= "      " . $date->get(Zend_Date::DAY_SHORT);

            }else

              $data .= "       ";

            $data .= "    </td>";

           

        }

       

        $data .= "  </tr>";

      }

      return $data;

  }

 

When running this code i get the following error:

Fatal error: Call to a member function get() on a non-object

on the line

CODE: SELECT ALL

$data .= "      " . $date->get(Zend_Date::DAY_SHORT);

 

if i just add the variable $date to the string, it prints the correct date. If i try to use the get_class method on $date it prints out Zend_Date, so it is obviously aware og the variable being of the type Zend_Date.

 

Why am I unable to access the methods of the object, and why does it claim that $date is not an object?

 

Any help will be much appreciated.

Hoffmeyer

 

 

Link to comment
https://forums.phpfreaks.com/topic/167387-non-object-from-array/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.