Skip to content
Advertisement

How to get the first element result in Php using foreach?

I tried to have this multi-dimensional array on Quotes>Sections>Departments I have a problem with getting the first iteration of the foreach-ed

JavaScript

Console::Log(‘actuals’, $actuals);

How to get the first element result in Php using foreach?

Thank you in advance

Advertisement

Answer

If $actuals is an array, you can access the first element via array notation. Arrays in php are 0 based.

JavaScript

Based on your statement that $actuals is an array with a number of associative keys within, you can get a human readable form using print_r, and passing the true parameter to return the output rather than printing it.

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement