New Features in Php 8.1 - Enums

Description An Enumerated type or enum is a data type that is used to demote a collection of specific type of data. It can contain a group of named values (also called enumerators of type). We can assign any of the allowed legal values to the variables in enum and any function can also type check against the enumerated type. - rfc Details Link: https://wiki.php.net/rfc/enumerations Authors: Larry Garfield, Ilija Tovilo Status: In Voting(date of writing) Target Version: PHP 8.

Stop Using in_array when possible

What is in_array() in_array() is a standard function in php which can be used to check if a value exists in array, duh! but sometimes, when the array size is relativly large this function can take a long time O(n). Example 1 2 3 4 5 6 7 8 $os = array("Mac", "NT", "Irix", "Linux"); if (in_array("Irix", $os)) { echo "Got Irix"; } if (in_array("mac", $os)) { echo "Got mac"; } ?