Arihant Arihant - 1 year ago 83
MySQL Question

How to get value of a key from a returned array from Laravel

A raw query in Laravel is returning the below output when I print_r() it.

Array ( [0] => stdClass Object ( [AUTO_INCREMENT] => 28 ) )

How can I extract just the value of AUTO_INCREMENT? In this example, the value being 28.

Answer Source

The value is a property from a stdClass.

Lets say you have this:

$result; \\your ex
echo $result[0]->AUTO_INCREMENT; \\this would echo 28.

You can read more here how to fetch property from object

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download