Jump to content

Array in header


avo

Recommended Posts

Hi All

 

Can anyone please put a end to my suffering ive been trying to do this for 1 hour

 

All i want to do is put the information from this array into a header redirection (header ('location: MY ARRAY');

 

first i start with a string place it in an array then add to the array with the loop then i would like to return this information (string) into the header.

 

$header_string= "some string" ;

$header = array() ;//empty array
$header = array($header_string) ;

	for ($i=1;$i<=$_POST['instruments_count'];$i++)
{
	$header[] ='&instument'.$i.'=instument'.$i ;
}

if (something){
header ('location: MY ARRAY') ;
}

 

Thanks in advance

Link to comment
Share on other sites

You would need to use the implode() function. Since the first query string is delimited from the domain part with a "?", not a "&", I wouldn't put the "&" into each array index. Here's what I would do:

 

<?php
$header_string= "some string" ;

$header = array() ;//empty array

	for ($i=1;$i<=$_POST['instruments_count'];$i++)
{
	$header[] ='instument'.$i.'=instument'.$i ;
}

if (something){
header ('location: ' . $header_string . '?' . implode('&',$header) ;
}?>

 

Ken

Link to comment
Share on other sites

Thank You

 

On testing im still finding no redirection i've printed this ~

 

echo $header_string . implode('&',$header) ;

 

All the information contained within looks good

 

I guess it as something to do with the straingness of the header () function.

 

 

Any ideas please..

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.