hoffmeyer Posted July 25, 2009 Share Posted July 25, 2009 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.