在$ _GET中使用implode

I have some forms in my page like :

    <form method="get">
Enter Your Firstname :<input type="text" name="t1"  />
Enter Your Lastname :<input type="text" name="t2"  />
<input type="submit" name="sb" />
</form>

so users will fill this form and i want to have values of this form separated with comma

for example

John,Smith
James,Baker

so here is my php code

if ( isset ($_GET['sb']))
{
    $t_array = array("t1","t2");
    foreach ( $t_array as $key ) 
    {
        echo implode(',' , $_GET[$key]);
    }
}

When i try to do this , i got this error :

Warning: implode() [<a href='function.implode'>function.implode</a>]: Invalid arguments passed in PATH on line 24

i don't know why i can't use implode in $_GET or $_POST

so how can i solve this problem ?

P.S : i want to use array and implode in my page , please don't write about other ways

What you need is something like below, you don't actually need implode for this:

if ( isset ($_GET['sb']))
{
    $t_array = array("t1","t2");
    $result = '';
    foreach ( $t_array as $key ) 
    {
        if ($result != '') $result .= ',';
        $result .= $_GET[$key];
    }
}

You're calling implode on a value, not an array. This code

echo implode(',' , $_GET[$key]);

calls it on $_GET[$key], which is a string.

You are trying for implode($_GET);.

You can't impode strings...

Try something like this:

if ( isset ($_GET['sb']))
{
    $t_array = array("t1","t2");
    $arr = array();
    foreach ( $t_array as $key ) 
    {
        $arr[] = $_GET[$key];
    }
    echo implode(',' , $arr);
}

There is an error in your logic.

here is sample code that might help you:

$t_array = array($_GET['t1'], $_GET['t2']);
$imploded = implode(',', $t_array);
echo $imploded;

This will work.