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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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