note 112388 deleted from function.array-push by peehaa

From: Date: Tue, 21 Mar 2017 08:36:29 +0000
Subject: note 112388 deleted from function.array-push by peehaa
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-208913@lists.php.net to get a copy of this message
Note Submitter: chris lanx ---- i wanted to do some string manipulation on a specific field from an sql result set and then append the row to the end of an array like this. [0] => [one] => [val1] [two] => [val2] [three] => [val3] [four] => [val4] [0] => [one] => [val1] [two] => [val2] [three] => [val3] [four] => [val4] ~I tried array push and couldnt get it sorted, So what i did was this. while ($row = mysql_fetch_assoc($query)) { $row['five'] = str_replace('.','',$row['place']); $results[] = $row; } resulting in [0] => [one] => [val1] [two] => [val2] [three] => [val3] [four] => [val4] [five] => [val5] [0] => [one] => [val1] [two] => [val2] [three] => [val3] [four] => [val4] [five] => [val5]

« previous php.notes (#208913) next »