avo Posted January 19, 2008 Share Posted January 19, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/86771-array-in-header/ Share on other sites More sharing options...
kenrbnsn Posted January 19, 2008 Share Posted January 19, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/86771-array-in-header/#findComment-443472 Share on other sites More sharing options...
avo Posted January 19, 2008 Author Share Posted January 19, 2008 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.. Quote Link to comment https://forums.phpfreaks.com/topic/86771-array-in-header/#findComment-443485 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.