note 29539 deleted from function.array-push by peehaa

From: Date: Tue, 21 Mar 2017 08:37:31 +0000
Subject: note 29539 deleted from function.array-push by peehaa
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-208916@lists.php.net to get a copy of this message
Note Submitter: daevid at daevid dot com ---- 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); ?>

« previous php.notes (#208916) next »