TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 01-27-2008, 07:41 AM   #1 (permalink)
The Addict
 
sarmenhb's Avatar
 
Join Date: Jan 2008
Location: los angeles
Posts: 309
Thanks: 44
sarmenhb is on a distinguished road
Smile question on functions

if i wrote something like this

Code:
<?php

function names($fname,$lname,$mname)
{

return array( '$FirstName' => '$fname',
	      '$LastName' => '$lname',
	      '$MiddleName' => '$mname');
}

names('sarmenhb','sarmenhb','sarmenhb');
names('a','b','c');
names('c','d','e');

?>

how can i output what the names function contains or how can i make use of this.

im beginning to think that arrays can be similar to ram like a temporary database or information storage that is volatile
__________________
no signature set
sarmenhb is offline  
Reply With Quote
Old 01-27-2008, 08:17 AM   #2 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by sarmenhb View Post
if i wrote something like this

Code:
<?php

function names($fname,$lname,$mname)
{

return array( '$FirstName' => '$fname',
	      '$LastName' => '$lname',
	      '$MiddleName' => '$mname');
}

names('sarmenhb','sarmenhb','sarmenhb');
names('a','b','c');
names('c','d','e');

?>

how can i output what the names function contains or how can i make use of this.

im beginning to think that arrays can be similar to ram like a temporary database or information storage that is volatile

What are you trying to do? You should make that a var then iterate the variable using foreach, and return the new iterated var. Otherwise it'll just output "Array"
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 01-27-2008, 08:26 AM   #3 (permalink)
The Addict
 
sarmenhb's Avatar
 
Join Date: Jan 2008
Location: los angeles
Posts: 309
Thanks: 44
sarmenhb is on a distinguished road
Default

Quote:
Originally Posted by Orc View Post
What are you trying to do? You should make that a var then iterate the variable using foreach, and return the new iterated var. Otherwise it'll just output "Array"

im reading this book and its starting to talk about OOP and its relation functions to classes and it showed that example.

i thought it was pretty cool. and wondered how i can make use of it.
__________________
no signature set
sarmenhb is offline  
Reply With Quote
Old 01-27-2008, 08:30 AM   #4 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by sarmenhb View Post
im reading this book and its starting to talk about OOP and its relation functions to classes and it showed that example.

i thought it was pretty cool. and wondered how i can make use of it.
you could try multidimensional arrays
PHP Code:
function array_multidim()
{
$array = array(
        array(
                
=> "Hello World!"
)
);
  
// Iterative Construct
  
foreach ($array as $a => $data)
  {

   return 
$a[$data];
  }

__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

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


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

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design