adding key-> value pair to an array

From: Date: Wed, 03 Dec 2008 09:01:11 +0000
Subject: adding key-> value pair to an array
Groups: php.general 
Request: Send a blank email to php-general+get-284045@lists.php.net to get a copy of this message
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(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;  } } Please somebody tell me how to achieve this. Thanks in advance. Aniket -- View this message in context: http://www.nabble.com/adding-key-%3E-value-pair-to-an-array-tp20809115p20809115.html Sent from the PHP - General mailing list archive at Nabble.com.

« previous php.general (#284045) next »