note 129586 added to language.types.array

From: Date: Fri, 14 Jun 2024 19:32:10 +0000
Subject: note 129586 added to language.types.array
Groups: php.notes 
Request: Send a blank email to php-notes+get-221377@lists.php.net to get a copy of this message
As PHP arrays are not really arrays but associative lists (dictionaries). Sometimes one needs to know if it was created as associative dictionary or as vector. There is one function that can do this https://www.php.net/manual/en/function.array-is-list <?php $a = ['a','b','a']; $b = ['a'=>'one','b'=>'two','c'=>3]; echo (array_is_list($a)?'true':'false') . '<br>'; echo (array_is_list($b)?'true':'false') . '<br>'; ?> returns true and false ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.5.137 (proxied: 185.159.157.11) ---- Manual Page -- https://php.net/manual/en/language.types.array.php Edit -- https://main.php.net/note/edit/129586 Del: integrated -- https://main.php.net/note/delete/129586/integrated Del: useless -- https://main.php.net/note/delete/129586/useless Del: bad code -- https://main.php.net/note/delete/129586/bad+code Del: spam -- https://main.php.net/note/delete/129586/spam Del: non-english -- https://main.php.net/note/delete/129586/non-english Del: in docs -- https://main.php.net/note/delete/129586/in+docs Del: other reasons-- https://main.php.net/note/delete/129586 Reject -- https://main.php.net/note/reject/129586 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#221377) next »