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

Reply
 
LinkBack Search this Thread
Old 06-13-2009, 01:24 PM   #1
eco
Member
 
Registered: May 2006
Location: BE
Distribution: Debian/Gentoo
Posts: 412

Rep: Reputation: 48
Post php array... can I have more than two values per entry?


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!
 
Old 06-13-2009, 03:43 PM   #2
jlinkels
Senior Member
 
Registered: Oct 2003
Location: Bonaire
Distribution: Debian Lenny/Squeeze/Wheezy/Sid
Posts: 3,975

Rep: Reputation: 476Reputation: 476Reputation: 476Reputation: 476Reputation: 476
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 03:48 PM.
 
Old 06-13-2009, 08:20 PM   #3
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,376

Rep: Reputation: 147Reputation: 147
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.
 
Old 06-15-2009, 04:51 PM   #4
eco
Member
 
Registered: May 2006
Location: BE
Distribution: Debian/Gentoo
Posts: 412

Original Poster
Rep: Reputation: 48
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
 
  


Reply

Tags
array, php


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are 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 09:33 PM
Java - Assigning Array Values en masse indienick Programming 11 08-23-2006 12:28 PM
extracting values from an array bahadur Programming 2 08-14-2006 01:07 AM
Problem displaying Bash array values. shinobi59 Programming 3 01-17-2006 05:45 PM
How to return values into an array using awk Helene Programming 1 05-01-2004 10:05 PM


All times are GMT -5. The time now is 02:21 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
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration