[TYPO3-mvc] How to transform objects to array

Xavier Perseguers xavier at typo3.org
Mon Jun 24 14:30:24 CEST 2013


Hi,

Stefan Kruse wrote:
>> Your problem is not clear. You have objects, meaning you have an array
>> of objects and the foreach loop works but you cannot access properties
>> of your objects or the foreach loop itself does not work?
> 
> Hi Xavier, thanks for replay. Its case number one. I have an array of
> objects. My foreach loop works but I cant access the the properties. Cheers
> Stefan.

Basically, this works like this inside your loop:

- If you have an array $person, writing person.firstName will access
$person['firstName']
- If you have an object $person, writing person.firstName will try to
access public field $firstName, if available, otherwise will fallback to
trying to get it via a public method getFirstName()

I don't know how your object looks like but you may need to modify them
or "cast" them to array before assigning them to Fluid (or write a
custom VH to extract info).

-- 
Xavier Perseguers
Release Manager TYPO3 4.6

TYPO3 .... inspiring people to share!
Get involved: http://typo3.org



More information about the TYPO3-project-typo3v4mvc mailing list