note 80311 added to language.types.array

From: Date: Wed, 09 Jan 2008 16:00:16 +0000
Subject: note 80311 added to language.types.array
Groups: php.notes 
Request: Send a blank email to php-notes+get-134971@lists.php.net to get a copy of this message
"If you convert a NULL value to an array, you get an empty array." This turns out to be a useful property. Say you have a search function that returns an array of values on success or NULL if nothing found. $values = search(...); Now you want to merge the array with another array. What do we do if $values is NULL? No problem: $combined = array_merge((array)$values, $other); Voila. ---- Server IP: 69.147.83.197 Probable Submitter: 121.209.219.53 (proxied: 127.0.0.1) ---- Manual Page -- http://www.php.net/manual/en/language.types.array.php Edit -- https://master.php.net/note/edit/80311 Del: integrated -- https://master.php.net/note/delete/80311/integrated Del: useless -- https://master.php.net/note/delete/80311/useless Del: bad code -- https://master.php.net/note/delete/80311/bad+code Del: spam -- https://master.php.net/note/delete/80311/spam Del: non-english -- https://master.php.net/note/delete/80311/non-english Del: in docs -- https://master.php.net/note/delete/80311/in+docs Del: other reasons-- https://master.php.net/note/delete/80311 Reject -- https://master.php.net/note/reject/80311 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#134971) next »