Graxeon Posted December 22, 2009 Share Posted December 22, 2009 I have an input converter. Basically, say I call "file.php?a=test1" well the "file.php" would run this: <?php if (isset($_GET['a'])) { $converter = array('blankspot' => 'blanks', 'test1' => '123', 'test2' => '321', 'blankspothere' => 'blank'); $a = $_GET['a']; if (isset($converter[$a)) { header("Location: $converter"); exit; } } ?> That would just redirect me to "123". However...now I want to have 2 things that the input converts into. Example: file.php?a=test1 That script gives it 2 converts like: <?php if (isset($_GET['a'])) { $converter = array('blankspot' => 'blanks', 'test1' => $x=123 and $y=456, 'test2' => $x=321 and $y=654, 'blankspothere' => 'blank'); $a = $_GET['a']; if (isset($converter[$a)) { header("Location: $x.$y"); exit; } } ?> That would redirect to "123456" I don't know how to give it 2 converts so my coding is wrong. Help please? Quote Link to comment https://forums.phpfreaks.com/topic/185957-input-converter/ Share on other sites More sharing options...
Graxeon Posted December 22, 2009 Author Share Posted December 22, 2009 Bump Quote Link to comment https://forums.phpfreaks.com/topic/185957-input-converter/#findComment-982413 Share on other sites More sharing options...
Buddski Posted December 22, 2009 Share Posted December 22, 2009 perhaps something like this.. $convX = array('test1'=>123,'test2'=>567); $convY = array('test1'=>456,'test2'=>890); if (isset($_GET['a']) && isset($convX[$_GET['a']]) && isset($convY[$_GET['a']])) { $loc = $convX[$_GET['a']] . $convY[$_GET['a']]; header('Location: '.$loc); } else { //No redirect } Quote Link to comment https://forums.phpfreaks.com/topic/185957-input-converter/#findComment-982417 Share on other sites More sharing options...
premiso Posted December 22, 2009 Share Posted December 22, 2009 <?php if (isset($_GET['a'])) { $converter = array('blankspot' => 'blanks', 'test1' => array('x' => 123, 'y' => 456), 'test2' => array('x' => 321, 'y' => 654), 'blankspothere' => 'blank'); $a = $_GET['a']; if (isset($converter[$a])) { if (is_array($converter[$a])) header("Location: {$converter[$a]['x']}{$converter[$a]['y']}"); else header("Location: {$converter[$a]}"); exit; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/185957-input-converter/#findComment-982418 Share on other sites More sharing options...
Graxeon Posted December 23, 2009 Author Share Posted December 23, 2009 I'm getting this error: Parse error: syntax error, unexpected T_STRING, expecting ')' in /file.php on line 4 Where exactly should the ')' be? Quote Link to comment https://forums.phpfreaks.com/topic/185957-input-converter/#findComment-983237 Share on other sites More sharing options...
Buddski Posted December 23, 2009 Share Posted December 23, 2009 Can you show us what line 4 is.. Quote Link to comment https://forums.phpfreaks.com/topic/185957-input-converter/#findComment-983239 Share on other sites More sharing options...
Graxeon Posted December 23, 2009 Author Share Posted December 23, 2009 This: 'test1' => array('x' => 123, 'y' => 456), Quote Link to comment https://forums.phpfreaks.com/topic/185957-input-converter/#findComment-983243 Share on other sites More sharing options...
Buddski Posted December 23, 2009 Share Posted December 23, 2009 Have you modified premiso's code in anyway from what was posted? Quote Link to comment https://forums.phpfreaks.com/topic/185957-input-converter/#findComment-983247 Share on other sites More sharing options...
Graxeon Posted December 23, 2009 Author Share Posted December 23, 2009 I just changed the numbers for X and Y. Quote Link to comment https://forums.phpfreaks.com/topic/185957-input-converter/#findComment-983249 Share on other sites More sharing options...
Buddski Posted December 23, 2009 Share Posted December 23, 2009 Can you post the whole code snippet again.. Quote Link to comment https://forums.phpfreaks.com/topic/185957-input-converter/#findComment-983253 Share on other sites More sharing options...
Graxeon Posted December 23, 2009 Author Share Posted December 23, 2009 It's alright, I got it to work. I took out the "else" and it's working perfectly. Thank you guys! Quote Link to comment https://forums.phpfreaks.com/topic/185957-input-converter/#findComment-983258 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.