LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Tags used in this thread
Popular LQ Tags ,

Reply
 
Thread Tools
Old 06-13-2009, 02:24 PM   #1
eco
Member
 
Registered: May 2006
Location: BE
Distribution: Gentoo/Debian/Kubuntu
Posts: 343
Thanked: 28
Post php array... can I have more than two values per entry?


[Log in to get rid of this advertisement]
Hi all,

I created a class which has to return an array.

My problem is I need to return 3 entries per record for example:
Code:
array( "2009-06-13", "John", "Doe";
       "2009-06-13", "Paul", "Simon";
       "2009-06-12", "Frank", "Herbert";
);
Can this be done? What is the syntax? Where is the documentation?

If this can't be done, How would you return this to a class without using a DB?

Many thanks!
eco is offline  
Tag This Post ,
Reply With Quote
Old 06-13-2009, 04:43 PM   #2
jlinkels
Senior Member
 
Registered: Oct 2003
Location: Bonaire
Distribution: Debian Etch/Lenny/Squeeze
Posts: 2,301
Thanked: 89
Smile

PHP Code:
function foo (){
  
$result=array( array("2009-06-13""John""Doe"),
                 array (
"2009-06-13""Paul""Simon"),
                 array (
"2009-06-12""Frank""Herbert")
       );
  return 
$result;

The documentation is on php.net.

jlinkels

Last edited by jlinkels; 06-13-2009 at 04:48 PM..
jlinkels is online now     Reply With Quote
Thanked by:
Old 06-13-2009, 09:20 PM   #3
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 11
Posts: 1,860
Thanked: 26
or since you are using classes already you can create a class that holds the three values in question and the array elements will be instances of the class.
graemef is offline     Reply With Quote
Thanked by:
Old 06-15-2009, 05:51 PM   #4
eco
Member
 
Registered: May 2006
Location: BE
Distribution: Gentoo/Debian/Kubuntu
Posts: 343
Thanked: 28

Original Poster
Thanks guys sorry for the late answer!

I like the idea of the Class but I'll get to that a little further down the line of my newb education
eco is offline     Reply With Quote

Reply

Bookmarks


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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to input values from *.txt to an array in C++ HBMSGUY Programming 6 11-18-2008 10:33 PM
Java - Assigning Array Values en masse indienick Programming 11 08-23-2006 01:28 PM
extracting values from an array bahadur Programming 2 08-14-2006 02:07 AM
Problem displaying Bash array values. shinobi59 Programming 3 01-17-2006 06:45 PM
How to return values into an array using awk Helene Programming 1 05-01-2004 11:05 PM


All times are GMT -5. The time now is 08:08 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration