I have nothing to do. I saw a lot of people doing random picture APIs. They are very handsome and very forced use Baidu Search php Code, I haven't learned php Any code, such as Xiaobai, is simply and rudely replaced by a line of code according to the gourd painting ladle. I don't know if there is a problem with the wood.
This code is very cool. You can use wildcards to represent the path. It's very small. I like it My picture home directory is images , the specific image file is placed in images Multiple subdirectories under the directory, so write as follows establish img. php , write the following code, and then reference img. php Web address
<? php //Get the image array in the folder $img_array = glob("./images/*/*.{gif,jpg,png}",GLOB_BRACE); //Select a random picture from the array $img = array_rand($img_array); //Show pictures on the page echo '<img alt="'.$img_array[$img].'" src="'.$img_array[$img].'" />'; ?
<? php //This will get an array of all gif, jpg and png images in a folder $img_array = glob("./images/*/*.{gif,jpg,png}",GLOB_BRACE); //Select a random picture from the array $img = array_rand($img_array); //Show pictures on the page header("location:.$img_array[$img]"); ?>