• 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

How do I set the maximum php memory limit

How to make a foreign key not using primary key

WHERE IN array binding in DB::raw laravel 5.4

PHPExcel How to set conditional formatting to change cell background color based on cells values

Method IlluminateAuthRequestGuard::logout does not exist Laravel Passport

Timber: Single post pagination does not work (wp_link_pages)

Ajax GET request fails in laravel 8

PHP Form Not Inserting

php mysql + create a friend request system

Woocommerce Edit Message "An account is already registered with your email address. Please log in."

Laravel - Browser displays message again when I press back button

CSV to PHP class properties

How to debug in WooCommerce 3+

Laravel Carbon throws error The format separator does not match

Use same method for inertia response and json response Laravel Jetstream

About Contact Privacy policy Terms and conditions