How can I determine where a specific element is in an array? For example, I have an array like this:
("itemone", "someitem", "fortay", "soup")
How do I get the index "someitem"
Thanks Christian Stewart
Use array_search()
array_search()
array_search - Searches for an array for the given value and returns the corresponding key, if successfulmixed array_search ( mixed $needle , array $haystack [, bool $strict ] )
array_search - Searches for an array for the given value and returns the corresponding key, if successful
array_search
mixed array_search ( mixed $needle , array $haystack [, bool $strict ] )
Example:
$key = array_search('someitem', $array);
$index = array_search('something', $myarray)
array_keys($array,$search); ()
array_keys($array,$search);
Source: https://habr.com/ru/post/1762088/More articles:C Unstringification with Macros - csecure php template template - phpCan I ignore or suppress warnings in JDBC for MySQL? - mysqlCMS and high traffic sites: PHP and MySQL - performanceFreezing Manipulation At Home - domC # - Adding an event handler for all instances of a class - c #Как удалить столбцы диапазона Excel VBA - excel-vbaHow to prevent unnecessary memory usage in recursive functions - c ++https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1762092/subversion-rearrange-repository&usg=ALkJrhi3kHT1GqhZHbk5zCSXldnphKjHMQssh bash файл завершения - bashAll Articles