problem working with an array of objects

This is a discussion on "problem working with an array of objects" within the PHP Forum section. This forum, and the thread "problem working with an array of objects are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Feb 12th, 2007, 06:06
New Member
Join Date: Jan 2007
Location: Manchester
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
problem working with an array of objects

Hi there. I'm an Java developer who has taken up PHP5 - drawn to it by its OO support. But I'm having difficulty achieving similar syntax when dealing with an array of objects.

In PHP, the following works on two lines, but not on one, thus requiring two variables to be instantiated.

$ranges = $this->collection->getRanges();
$this->range = $ranges[0];

I don't need to assign to the variable $ranges, bt I can't seem to use the syntax:

$this->range = ($this->collection->getRanges())[0];

I thought perhaps I might need to cast the array, but this doesn't hepl i.e.

$this->range = ((Ranges)$this->collection->getRanges())[0];

any ideas?
Reply With Quote

Reply

Tags
array objects

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Fetch Array problem Aso PHP Forum 3 Dec 4th, 2007 16:13
Removing objects in an array breepupetstofight ASP.NET Forum 0 Sep 17th, 2007 13:00
Sorting a new array from an existing array Ozeona Flash & Multimedia Forum 2 Sep 20th, 2005 08:43
array unable to check another array so as to be displayed Ozeona Flash & Multimedia Forum 1 Aug 5th, 2005 10:26
Array problem netwarriorgizmo JavaScript Forum 1 Jul 12th, 2004 21:25


All times are GMT. The time now is 01:49.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43