Jump to content

php function help?


nochlux

Recommended Posts

Suppose I have this code

 

$num = $_SESSION['count'];

$_SESSION['a'][$num] = $a_letter;

$_SESSION['b'][$num] = $b_letter;

$_SESSION['c'][$num] = $c_letter;

$_SESSION['d'][$num] = $d_letter;

$_SESSION['e'][$num] = $e_letter;

$_SESSION['f'][$num] = $f_letter;

 

 

 

if(!exists) {

 

$num = $_SESSION['count'];

$_SESSION['a'][$num] = $a_letter;

$_SESSION['b'][$num] = $b_letter;

$_SESSION['c'][$num] = $c_letter;

$_SESSION['d'][$num] = $d_letter;

$_SESSION['e'][$num] = $e_letter;

$_SESSION['f'][$num] = $f_letter;

}

 

 

else {

$num = $_SESSION['count'];

$_SESSION['a'][$num] = $a_letter;

$_SESSION['b'][$num] = $b_letter;

$_SESSION['c'][$num] = $c_letter;

$_SESSION['d'][$num] = $d_letter;

$_SESSION['e'][$num] = $e_letter;

$_SESSION['f'][$num] = $f_letter;

 

}

 

Now I don't want those codes to copy paste repetitively, but instead I want to come up with a function - So I probably have to create a function in php then??

 

 

function list ()

 

{

$num = $_SESSION['count'];

$_SESSION['a'][$num] = $a_letter;

$_SESSION['b'][$num] = $b_letter;

$_SESSION['c'][$num] = $c_letter;

$_SESSION['d'][$num] = $d_letter;

$_SESSION['e'][$num] = $e_letter;

$_SESSION['f'][$num] = $f_letter;

 

}

 

$value = function list();

 

if (!exists)

 

{

$value

 

}

 

 

else {

 

$value

 

}

 

How does this work please?

Link to comment
https://forums.phpfreaks.com/topic/278008-php-function-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.