如何从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.

Laravel中的原始查询在print_r()时返回以下输出。 p>

数组([0] => stdClass对象([AUTO_INCREMENT] => 28)) p> blockquote>

如何只提取AUTO_INCREMENT的值? 在此示例中,值为28. p> div>

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