Aniketto wrote: > Hi all, > Can anybody tell me how can I add key->value pair in an array. > My code is as follows > > $criteria = array(); > $criteria['mail_subject'] = $form->subject->getValue(); > $criteria['delivery_user_name'] = $form->delivery_user_name->getValue(); > $criteria['start_date'] = $form->start_date->getValue(); > $criteria['end_date'] = $form->end_date->getValue(); > $criteria['group'] = $form->group->getValue(); > > // get table data from database > $rowset = $mailDelivery->findDeliveryMailData($criteria); > > //convert rowset into an array > $mailDataArray = $rowset->toArray(); > if you do a print_r() right here on $mailDataArray, what does it look like? > > if(count($mailDataArray) != 0){ > foreach($mailDataArray as $row){ > $condition['mail_delivery_id'] = $row->id; > $browseCount = $mailDeliveryDetail->findBrowseCount($condition); > $totalCount = $mailDeliveryDetail->findTotalCount($condition); > //for each row I want to add percentage as new key->value pair > // but it gives error 'Undefined variable: > percentage' > $row->$percentage = ($browseCount / $totalCount ) * 100; Were you intending to just say $row->percentage instead of calling $percentage? > } > } > > > Please somebody tell me how to achieve this. > Thanks in advance. > Aniket -- Jim Lucas "Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them." Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php