ShadowMage Posted January 19, 2010 Share Posted January 19, 2010 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 More sharing options...
Ingolme Posted January 19, 2010 Share Posted January 19, 2010 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 More sharing options...
ShadowMage Posted January 19, 2010 Author Share Posted January 19, 2010 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.