lets say i have a get variable:

$goto=$_GET['goto'];

and i have a array

$sections= array('fail' => fail());

how would i make it so when the $goto=fail, it does the function fail from the array?

But I want the array goto to call a function

function foo()
{
echo "thanks for calling";
}
$goto=$_GET['goto'];
$sections= array('fail','success');
if(in_array($goto,$sections))
{
foo();
  //call the function u want to call here
}

But I want the function to vary on the goto

function foo($goto)
{
echo "thanks for calling".$goto;
}
$goto=$_GET['goto'];
$sections= array('fail','success');
if(in_array($goto,$sections))
{
foo($goto);
  //call the function u want to call here
}

Hope this is what u r looking for
PS-Mark the thread as solved if your porblem is solved..

Ok, what I want is goto is the get variable. I want an Array that has different things pointing to functions. And if the goto is one of the things, then it does the function the goto it pointing to

look at my post again. It does what you want. If you look at YOUR post you have: $sections= array('fail' => fail()); what you are doing there is initializing $sections to whavever fail() returns.

To clarify, if you have:

<?php
function fail(){
return 'hello';
}
$sections= array('fail' => fail());
?>

What YOU are really doing is initializing $sections to "hello".

Based on your description, what you are HOPING to do is to be able to call fail() based on whatever $_GET['goto'] has, which is what I gave you.

If you are going to have:
$sectionsfail[/B]'] call fail()

it will be simpler to just "LIST" the functions in an array: $sections=array("fail"); and if the value of $goto is in $sections, just call $goto();

@tcollins412-The code posted by hielo and tomato.pgn is doing the same thing what you have asked for.....
If you want something different then give a suitable example to explain us your problem...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.