Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
<?php
function my_function($array_args)
{
extract($array_args);
// do whatever you want with $var1, $var2, etc...
}
// Then you can just call it with:
$returnval = myfunction(array(
$var1=>"value1",
$var2=>"value2",
$var3=>"etc..."
);
?>
<?php
// default args in array
function do_something($arr = array('var1'=>"default1",'var2'=>"default2"))
{
echo $arr["var1"] . '--' . $arr["var2"];
}
// call with no args, outputs defaults
do_something();
echo "<br><br><br>";
// call with args, outputs args
do_something(array(
"var1"=>"Something else",
"var2"=>"Some more of that"));
?>
<?php
function do_something($arr = array(
'var1'=>"default1",
'var2'=>"default2"))
{
echo $arr["var1"] . '--' . $arr["var2"] . "<br>\n";
// arbitrary numbered args:
$i = 0;
while($arr[$i]){
echo $arr[$i] . "<br>\n";
$i++;
}
}
// call with args, outputs args
do_something(array(
"var1"=>"Something insane",
"var2"=>"More more more",
0=>"first arbitrary arg",
1=>"second arbitrary arg",
2=>"third arbitrary arg"
));
?>
global
function change_globally($normalparam) {
global $originalparm1, $originalparm2, $originalparm3;
$originalparm1 = $normalparam*5;
$originalparm2 = 'string';
$originalparm3 = $normalparam . 'x';
}