note 29539 modified in function.array-push by vrana
| From: | vrana@php.net | Date: | Tue, 17 Aug 2004 14:48:20 +0000 |
| Subject: | note 29539 modified in function.array-push by vrana | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-79744@lists.php.net to get a copy of this message | ||
Sadly, array_push() does not create an array if the array doesn't exist. So if you're
pushing the first element onto an array, you need to check and create it manually...
<?php
if ( !is_array($myArray) ) $myArray= array();
array_push($myArray, $myElement);
?>
--was--
Sadly, array_push() does not create an array if the array doesn't exist. So if you're
pushing the first element onto an array, you need to check and create it manually...
if ( !is_array($myArray) ) $myArray= array();
array_push($myArray, $myElement);
http://php.net/manual/en/function.array-push.php