• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

Why do I have invalid argument supply for foreach in Laravel for json response? [duplicate]

phpjqueryajaxlaravellaravel-5


PHP Snippet 1:

//...
$product  = json_decode($request->product, true);
//...

PHP Snippet 2:

 public function dopayment(Request $request) {

            $input = $request->all();

            $product = json_decode($request->product);


            foreach ($product as $single) {
                # code...

                print_r($single->name);
            }

           print_r($product);
            exit;
        }

PHP Snippet 3:

if (is_array($product ) || is_object($product ))
{
    foreach($product as $arrayItems){
      // Perform x.
    }
}

Related Snippets

Is it possible to change the table name in the migration file-laravel

Target class controller does not exist - Laravel 8

How to prevent phpmailer sending embedded image as an attachment on Gmail?

How to get unique slug to same post-title for other time too?

PHP - CURL using HTTPS [closed]

Invalid value in field "itemtype" in Google Search Console

add uri parameter to Route name in laravel

How to create custom authentication in laravel 8?

PHP Warning: Module already loaded in Unknown on line 0

Minimum order amount except for specific shipping method in WooCommerce

Laravel Pagination links() not working

Passing a boolean value from checkbox in Laravel form

Is it possible to change the table name in the migration file-laravel

Xdebug in Laravel is not working with VSCode

jQuery Ajax Post with data

About Contact Privacy policy Terms and conditions