Skip to content
Advertisement

Tag: arrays

Array inside arrays of arrays

I need help, I can’t assign the single values of the array inside the array of the array to a variable. I could assign the values of the second dimension array to single variables like this: But how can I use a second loop to count and extract the single values of the products?I have tried with a second “for”

how to convert $request format in laravel

I search around for a bit but found nothing that did exactly what I’m after nor anything that really aided me in achieving what I’d like I have data in this format: I’d like to convert it all to this format: i tried: but get no success Answer You got it the other way around. You need to loop on

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 the business and the stock value.

Advertisement