Use the second parameter of json_decode to make it return an array:

$result = json_decode($data, true);
Answer from Jon on Stack Overflow
🌐
GitHub
github.com › webonyx › graphql-php › issues › 456
PHP "Cannot use object of type stdClass as array" · Issue #456 · webonyx/graphql-php
March 18, 2019 - PHP "Cannot use object of type ... this PHP error on line 165 of src/Utils/Value.php · It occurs whenever I try to use a non-scalar type for a mutation argument....
Discussions

forms - Cannot use object of type stdClass as array error in node save - Drupal Answers
I built a custom form and one of them is of type geocode with lat/lon fields. When I try to save the node I receive the following error: Cannot use object of type stdClass as array in /var/www/ More on drupal.stackexchange.com
🌐 drupal.stackexchange.com
[SOLVED] 0 Cannot use object of type stdClass as array.
I am nor sure if there some king of connection with an issue I am having with Kunena during my migration from Joomla 3 to Joomla 4. I am just trying to... More on joomlapolis.com
🌐 joomlapolis.com
April 5, 2024
7 - Fatal error: Cannot use object of type stdClass Error help! - Drupal Answers
When trying to access my image file from my database i get this error: Fatal error: Cannot use object of type stdClass as array in C:\wamp\www\drupal-7.25\sites\all\modules\database\database_ex.m... More on drupal.stackexchange.com
🌐 drupal.stackexchange.com
September 9, 2014
Cannot use object of type stdClass as array - Addons, modules and themes developers - PrestaShop Forums
Hello, I've noticed that my review module stopped to send reminder emails to my customers. When I start cron job manually I'm getting #500 error. Debug mode shows a message like in the attachment. The Reminder.php line 254: 253: foreach ($data_task as $k1 => $product) { 254: if (in_array($prod... More on forum.prestashop.com
🌐 forum.prestashop.com
June 13, 2024
🌐
Medium
medium.com › @discretematt › fatal-error-uncaught-error-cannot-use-object-of-type-stdclass-as-array-in-e9d5ee5477c2
Fatal error: Uncaught Error: Cannot use object of type stdClass as array in | by Matt | Medium
August 28, 2024 - “Fatal error: Uncaught Error: Cannot use object of type stdClass as array in” is an error that occurs in PHP when working with a JSON object.
🌐
LTHEME
ltheme.com › home › blog › troubleshoot › cannot use object of type stdclass as array
Cannot use object of type stdclass as array - LTHEME
March 31, 2022 - Because once you utilize json_decode(); function, it returns an object of type stdClass. Whereas, the arguments which are to be passed inside of print_r() should either be a string or an array.
🌐
YouTube
youtube.com › wppluginsforyou
How to solve "Cannot use object of type stdClass as array" in WordPress? - YouTube
Learn how to fix the 'Cannot use object of type stdClass as array' error in PHP with this easy-to-follow video tutorial. This error occurs when you're trying...
Published: May 10, 2023
Views: 539
🌐
Laracasts
laracasts.com › discuss › channels › general-discussion › cannot-use-object-of-type-stdclass-as-array-1
Cannot use object of type stdClass as array
You need to add get() to execute the query in order to fetch the array of data · DB::select('SELECT * FROM rent ORDER BY id ASC')->get(); But you should work to learn more about Laravel and eloquent because your code could be vastly improved.
🌐
Stack Exchange
drupal.stackexchange.com › questions › 266844 › cannot-use-object-of-type-stdclass-as-array-error-in-node-save
forms - Cannot use object of type stdClass as array error in node save - Drupal Answers
Share · Improve this answer · Follow · answered Aug 2, 2018 at 21:33 · kombogdan · 12144 bronze badges 13 · Actually, it's the opposite. The error is Cannot use object of type stdClass as array, which means the code is using an object as array.
Find elsewhere
🌐
Joomlapolis
joomlapolis.com › forum › support and presales › developer members support › [solved] 0 cannot use object of type stdclass as array.
[SOLVED] 0 Cannot use object of type stdClass as array. - Joomlapolis Forum
April 5, 2024 - I am nor sure if there some king of connection with an issue I am having with Kunena during my migration from Joomla 3 to Joomla 4. I am just trying to source ou the meaning of the error message "0 Cannot use object of type stdClass as array' When not logged in I only see bits of the bulletin board, but once logged in only see the above message.
🌐
Programming
programming.gonevis.com › fixing-cannot-use-object-of-type-stdclass-as-array-error-in-php
Fixing "Cannot use object of type stdClass as array" Error in PHP - Programming
July 18, 2025 - To fix the error, use object notation (->) to access the data inside the stdClass object. $data = json_decode($json_string, true); // true argument creates an associative array // or $data = json_decode($json_string); echo $data->context; // ...
🌐
Joomla
forum.joomla.org › board index › joomla! versions which are end of life › joomla! 3.x - end of life 17 aug 2023 › templates for joomla! 3.x
Cannot use object of type stdClass as array after update - Joomla! Forum - community, help and support
June 27, 2018 - You also can fix it by open the following file ‘/plugins/system/helix3/helix3.php’, go o line 49 you will see PHP code JForm::addFormPath(JPATH_PLUGINS.’/system/helix3/params’); just replace it to JForm::addFormPath(JPATH_PLUGINS.’/system/helix3/params’); if (is_object($data)) { $data = (array)$data; } ... I have this problem an i cant make a new menu item. Any help? An error has occurred. 0 Cannot use object of type stdClass as array /var/www/vhosts/eshopfairytale.gr/httpdocs/plugins/system/vpframework/helper.php:928 Call stack # Function Location 1 () JROOT/plugins/system/vpframe
🌐
CodeIgniter
forum.codeigniter.com › showthread.php
Cannot use object of type stdClass as array
June 21, 2016 - CodeIgniter Forums Using CodeIgniter General Help Cannot use object of type stdClass as array · Share on Google · Share on Facebook · Share on Twitter · View a Printable Version · Subscribe to this thread · Add Poll to this thread · Send thread to a friend ·
🌐
Drupal
drupal.org › project › mandrill › issues › 3265663
Cannot use object of type stdClass as array
March 30, 2022 - Problem/Motivation The following error occurs when sending a template mail: Error: Cannot use object of type stdClass as array in Drupal\mandrill\MandrillService->handleSendResponse() (line 180 of /var/web/vd19353/deploy/releases/20220216143247/web/modules/contrib/mandrill/src/MandrillService.php) #0 /var/web/vd19353/deploy/releases/20220216143247/web/modules/contrib/mandrill/modules/mandrill_template/src/MandrillTemplateService.php(63): Drupal\mandrill\MandrillService->handleSendResponse(Array, Array) #1 /var/web/vd19353/deploy/releases/20220216143247/web/modules/contrib/mandrill/src/Plugin/M
🌐
WordPress
wordpress.org › support › topic › fatal-error-uncaught-error-cannot-use-object-of-type-stdclass-as-array-2
Fatal error: Uncaught Error: Cannot use object of type stdClass as array | WordPress.org
June 25, 2024 - “Fatal error: Uncaught Error: Cannot use object of type stdClass as array in /home/wecoopd/www/wp-admin/update-core.php on line 520
🌐
PrestaShop Forums
forum.prestashop.com › international community (english) › prestashop developers › addons, modules and themes developers
Cannot use object of type stdClass as array - Addons, modules and themes developers - PrestaShop Forums
June 13, 2024 - Hello, I've noticed that my review module stopped to send reminder emails to my customers. When I start cron job manually I'm getting #500 error. Debug mode shows a message like in the attachment. The Reminder.php line 254: 253: foreach ($data_task as $k1 => $product) { 254: if (in_array($prod...
🌐
Wikitechy
wikitechy.com › technology › cannot-use-object-of-type-std-class-as-array
[ Solved - 8 Answers ] PHP - Cannot use object of type stdClass as array - Wikitechy
March 28, 2017 - If we want to fetch value through array, set assoc to true. ... Change our code from: [pastacode lang=”php” manual=”$result[’context’]; ” message=”Php Code” highlight=”” provider=”manual”/] To: [pastacode lang=”php” manual=”$result->context; ” message=”Php ...
🌐
JoomShaper
joomshaper.com › forum › question › 26299
0 Cannot Use Object Of Type StdClass As Array - Question | JoomShaper
I started gettings this message after upgrading to J4 & SP PB 5. I restored a backup made before the upgrade but it hasn't fixed the problem. I can work at the backend of Joomla without a problem as long as I don't try to edit SP PB pages. when I try to edit, I get this error message: 0 Cannot use object of type stdClass as array
🌐
PHP
php.net › manual › en › class.stdclass.php
PHP: stdClass - Manual
However, it is possible to create a custom class that extends stdClass and as a result inherits the functionality of dynamic properties. ... This class has no methods or default properties. Example #1 Created as a result of typecasting to object · <?php $obj = (object) array('foo' => 'bar'); ...