Skip to content

How do you find the closest value to a number in an associative array?

I have an associative array with 15 different companies and their stock prices, formatted as shown below: I have found the average stock price: The average ends up being 161. But I now need to find the closest number (absolute terms) to that average value (161) within the associative array. I need to display …

imagecreatefromweb causing FATAL error which cannot be caught

I have a simple block of code that when fed an invalid file should be able to provide some user feedback, but I am finding the call to imagecreatefromweb** simply stops all PHP processing with a “Fatal error: gd-webp cannot get webp info in ..” straight away. I have tried to place this in a try ca…