The14thGOD Posted March 24, 2007 Share Posted March 24, 2007 Working on a mini project, and when the page first loads it works correctly. The link is domain.com?collapse=2,1,1 Once I click the link, and it refreshed, the link reads as: domain.com?collapse=,1,1 I'm not sure why... so heres the code b4 the beginning of the html tag: <?php $thispage = $_SERVER['PHP_SELF']; $thispage .= "?collapse="; //array if (!$_GET['collapse']) { $array = array(1,1,1); }else { $collapse = $_GET['collapse']; $array = explode(",", $_GET['collapse']); echo($array[0]); } ?> code for the link: <?php $thispage2 = "$thispage"; if ($array[0] == 1) { $sub0 = 2; $thispage2 .= "$sub0,$array[1],$array[2]"; }else{ $sub0 == 1; $thispage2 .= "$sub0,$array[1],$array[2]"; } echo($thispage2); ?> So the problem is, why is the $sub0 after you click the link one time reading as nothing... Any help would be appreciated. Thanks in advanced, The14thGOD Link to comment https://forums.phpfreaks.com/topic/44173-array-not-reading-right/ Share on other sites More sharing options...
wildteen88 Posted March 24, 2007 Share Posted March 24, 2007 You are doing a comparision rather than an assignment operation: $sub0 == 1; change that to: $sub0 = 1; and your code will work how you want it to. Link to comment https://forums.phpfreaks.com/topic/44173-array-not-reading-right/#findComment-214498 Share on other sites More sharing options...
The14thGOD Posted March 24, 2007 Author Share Posted March 24, 2007 ah, thanks, damn, i should have looked for minor errors like that. thanks Link to comment https://forums.phpfreaks.com/topic/44173-array-not-reading-right/#findComment-214507 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.