PHP makes a verification code, mainly using array-related functions
<?php Header ("Content-type:text/html;charset=utf-8"); Set up 3 range array $shuzi = range (0,9); $zimuda = Range (' A ', ' Z '); $zimuxiao = Range (' A ', ' Z '); Merge these 3 arrays into a new array $arr =array_merge ($shuzi, $zimuxiao, $zimuda); Iterate through the new array foreach ($arr as $key + $value) { //If the element in the new array contains the following word, delete it (unset); if ($value = = ' 0 ' | | $value = = ') 1 ' | | $value = = ' 2 ' | | $value = = ' o ' | | $value = = ' O ' | | $value = = ' I ' | | $value = = ' I ' | | $value = = ' Z ' | | $value = = ' Z ' | | $value = = ' L ') { //delete key, the value is also deleted unset ($arr [$key]);} } The array element is scrambled, and its key value follows the element is disturbed shuffle ($arr); The 4 key values of the original array are randomly taken $arr _rand = Array_rand ($arr, 4); The key of the original array is traversed output to get 4 random verification Code foreach ($arr _rand as $value) { echo $arr [$value]; } Optimization: 0,1,2 These 3 numbers originally need to exclude, just in the array of the first, continuous, in the definition of the range array can not write, directly from 3, reduce if judgment; uppercase and lowercase z can not be written at the end