Jump to content

Array not reading right


The14thGOD

Recommended Posts

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

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.