• 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

Ajax GET request fails in laravel 8

php curl requesting twice

How can I pass the list to the component variable in Laravel?

How can I remove the "Advanced" panel of all blocks in WordPress block editor?

Check if string contains a value in array [duplicate]

Fatal error: Array callback has to contain indices 0 and 1

How to keep value of selected value after form submission?

How to get monthly wise data in laravel

Transpose csv file data [duplicate]

oauth-private.key does not exist or is not readable

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

Woocommerce Checkout - Add conditional field required if one field is filled

Using spatie/media-library, how to rename a collection of uploaded files?

How do I enable error reporting in Laravel?

Laravel Unresolvable dependency resolving [Parameter #0 [ <required> $method ]] in class GuzzleHttpPsr7Request

About Contact Privacy policy Terms and conditions