See the new scripts recently added to Dynamic Drive. Click here.
Original, practical CSS codes and examples such as CSS menus for your site.
-->
    Search code samples  
 
  Keyword
 
 
 
   
 
 
  Code Samples
 
ASP
CSS
Dhtml
Html
Javascript
PHP
 
   
     LOGIN HERE  
 
Username
Password
Forgot Password
Verify Signup
 
 
 

PHP >> General

How do you return an array from a function?

Visitor Ratings (2) :

Description
Returning an array is like returning any other type of variable in
PHP. They work great as parameters too. Here's an example:

function add_fruit($a, $b) {
return array($a, $b, 'cranberry');
}

$fruits = add_fruit('apple','banana');

foreach ($fruits as $key => $fruit) {
print "$key : $fruit <br>";
}

0 : apple <br>
1 : banana <br>
2 : cranberry <br>

You can also use use 'global' to make variables (such as arrays)
available outside the scope of the function. So:
Code
Select All
 Rate this Resource
Related Links:
PageRank




Earn revenue from 
your website's traffic.






Reliable hosting for $6.95!

FreeLance Jobs from ODesk!



 
Home    Blog    Ajax    CSS    Hot scripts    Tips & Tricks    Webmaster Resources     Freelance jobs    Articles    Sitemap    Website builder and Cheap domain names    Lotus Notes FAQ    Our partners