array variable assignment problems
Posted: Tue Aug 03, 2004 7:49 am
I have problems with the section of code below, data stored by $salesPerson is an array containing other arrays as its elements. Now the main problem is that the for loop performs an indefinite loop. I still can't see what's the problem after spending several hours on this. Assigning values like this works fine -> $salesPerson[0]['totalComm'] = 0;
Code: Select all
<?php
$salesPeople = new salesPerson();
$salesPerson = $salesPeople->getSalesPersonnel();
if($salesPerson['success'] == 0){
print($salesPerson['errMsg']);
return;
}
//remove the first array element containing 'None'
array_shift($salesPerson);
//initialise array elements
for($i=0;$i<count($salesPerson);$i++){
$salesPerson[$i]['totalComm'] = 0;
$salesPerson[$i]['commPercent'] = 0;
$salesPerson[$i]['exhibition'] = 0;
$salesPerson[$i]['exhibitionSales'] = 0;
$salesPerson[$i]['showroom'] = 0;
$salesPerson[$i]['showroomSales'] = 0;
$salesPerson[$i]['referral'] = 0;
$salesPerson[$i]['referralSales'] = 0;
$salesPerson[$i]['designer'] = 0;
$salesPerson[$i]['designerSales'] = 0;
$salesPerson[$i]['contractor'] = 0;
$salesPerson[$i]['contractorSales'] = 0;
}
?>