Jump to content

Isset Always False


ShadowMage

Recommended Posts

Hi, I have a bit of a confusing situation here. Well, maybe it's not. Anyway here's the code that's giving me trouble:

//Create the array for the part$arrTempParts[$tmpArrIndex] = array();if (isset($arrTempParts[$tmpArrIndex][$index_PartNumFull])) {	if ($arrTempParts[$tmpArrIndex][$index_PartNumFull] != '') {		$arrTempParts[$tmpArrIndex][$index_PartNumFull].=";";	}	$arrTempParts[$tmpArrIndex][$index_PartNumFull].=$tmpCurrPartFull;	if ($tmpCurrPartBase == '0141') { //Test to see where the if executes		echo "Set: ".$tmpCurrPartFull."; ".$arrTempParts[$tmpArrIndex][$index_PartNumFull]."<br />";	}} else {	$arrTempParts[$tmpArrIndex][$index_PartNumFull] = $tmpCurrPartFull;	if ($tmpCurrPartBase == '0141') { //Test to see where the if executes		echo "Not Set: ".$tmpCurrPartFull."; ".$arrTempParts[$tmpArrIndex][$index_PartNumFull]."<br />";	}}

The isset statement above for some reason always returns false. Can anyone see why this would be happening?Thanks

Link to comment
Share on other sites

You're creating the array:

$arrTempParts[$tmpArrIndex] = array();

But it's empty, it has no indices, so nothing that you search for in it will exist.$arrTempParts[$tmpArrIndex] exists.$arrTempParts[$tmpArrIndex][$index_PartNumFull] does not exist.

Link to comment
Share on other sites

Silly me. The array creation should be in an if statement too.

if (!isset($arrTempParts[$tmpArrIndex])) {   $arrTempParts[$tmpArrIndex] = array();}

My snippet is inside a loop and I'm cumulating values. The way I had it before resets the array every time the loop passes.Thanks Ingolme for pointing me in the right direction :)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...