Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Returning Multiple Variables in Array
Old 06-06-2009, 07:13 AM Returning Multiple Variables in Array
lothop's Avatar
Ultra Talker

Posts: 303
Trades: 0
Hey guys and gals, I checked the net trying to find how to return multiple variables and they said to return it as an array.

This is what Ive got.

PHP Code:
function displayProblems($newsize) {
    
$sql_text "SELECT points FROM ".$this->TABLES['limits']." WHERE points = '$newsize'";
    
$data $this->sql->Select($sql_text);
    
$i=0;
list(
$core$lord) = f(); 
$str .=' core -'.$core.' lord -'.$lord.'';
    return 
$str;
  }

function 
f() {
    
$sql_text "SELECT type FROM ".$this->TABLES['currentarmy']."";
    
$data $this->sql->Select($sql_text);
    
$i=0;
    
$len count($data);
    
$core=0;
    
$lord=0;
for (
$i=0$i$len$i++) {
switch(
$data[$i]['type']){
   case 
'core':$core=($core+1);break;
   case 
'lord':$lord=($lord+1);break;
 }
    }
return array (
$core$lord); 
  } 
But I keep getting Fatal error: Call to undefined function f() in functions.php on line 79. Any ideas?
__________________
Websites Created;
warscope.com
ratepayers.org.nz
lothop is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-06-2009, 07:16 AM Re: Returning Multiple Variables in Array
lothop's Avatar
Ultra Talker

Posts: 303
Trades: 0
Upon posting this I found the problem was
PHP Code:
list($core$lord) = f(); 
It needed to be
PHP Code:
list($core$lord) = $this->f(); 
__________________
Websites Created;
warscope.com
ratepayers.org.nz
lothop is offline
Reply With Quote
View Public Profile
 
Old 06-06-2009, 08:24 AM Re: Returning Multiple Variables in Array
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
You didn't give us any clue that those functions were inside of a Class.
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.
wayfarer07 is online now
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 06-06-2009, 07:06 PM Re: Returning Multiple Variables in Array
lothop's Avatar
Ultra Talker

Posts: 303
Trades: 0
Yeah
Except using $this-> in other areas.

".$this->TABLES['limits']."
Its all sorted now though
__________________
Websites Created;
warscope.com
ratepayers.org.nz
lothop is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Returning Multiple Variables in Array
 

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.21397 seconds with 12 queries