**how can i pass an associative array and fetch that same array in submitted page with key=>value format.
**

<?php
//I SUBMIT a.phhp PAGE IN THIS PAGE//
 $f=$_REQUEST['1'];//1st input field value of a.php page
 $s=$_REQUEST['2'];//1st input field value of a.php page
 $t=$_REQUEST['3'];//1st input field value of a.php page
 $sub=$_REQUEST['s'];
 $arr=array($f,$s,$t);

//$arr=array('a'=>"$f","b"=>"$s","c"=>"$t");//i want to send like this as an associative array

 $str=implode(',',$arr);

switch($sub)
{
case 's1':
echo "<script>window.location.href='j2.php?val=$str'</script>";
break;

case 's2':
echo "<script>window.location.href='j3.php?val=$str'</script>";
break;

case 's3':
echo "<script>window.location.href='j4.php?val=$str'</script>";
break;
}
?>

WHAT WILL BE CODE IN PAGE j2.php/j3.php/j4.php TO FETCH $f,$s,$t value with key=>value format(a=>$f,b=>$s,c=>$t)

Member Avatar for diafol

Instead of passing them, why not include them?

switch($sub)
{
case 's1':
    include "j2.php";
    break;
case 's2':
    include "j3.php";
    break;
case 's3':
    include "j4.php";
    break;
}

Unless you have to go physically to those pages. In which case, save to session variable:

<?php
session_start();
//I SUBMIT a.phhp PAGE IN THIS PAGE//
 $f=$_REQUEST['1'];//1st input field value of a.php page
 $s=$_REQUEST['2'];//1st input field value of a.php page
 $t=$_REQUEST['3'];//1st input field value of a.php page
 $sub=$_REQUEST['s'];

$arr=array('a'=>$f,"b"=>$s,"c"=>$t);

$_SESSION['store'] = $arr;

switch($sub)
{
case 's1':
    header("Locatiob: j2.php");
    exit;
    break;
case 's2':
    header("Locatiob: j3.php");
    exit;
    break;
case 's3':
    header("Locatiob: j4.php");
    exit;
    break;
}
?>

You then pick up the session var in those pages. Also don't use $_REQUEST, use either $_POST or $_GET.

//edit
you don't need the breaks in the switch.

great .....thnk a ton...actually it was a question ask by interviewer.the quistion was.HOW DO TOU SUBMIT A FORM WITH FORM DATA TO 3 DIFFERENT PAGE USING 3 DIFFERENT SUBMIT BUTTON?so at that instance i got this solution..DO YOU HV ANY OTHER SOLUATION?I know u obiously hv a no of solution.pls share some

Member Avatar for diafol

Google it?

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.