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
https://forums.phpfreaks.com/topic/86771-array-in-header/
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
https://forums.phpfreaks.com/topic/86771-array-in-header/#findComment-443472
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
https://forums.phpfreaks.com/topic/86771-array-in-header/#findComment-443485
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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