• 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

Passing PHP JSON to Javascript: echo json_encode vs echo json declaration

auth pages not getting css in laravel

Display specific shipping method if woocommerce product has specific acf field value

Warning: A non-numeric value encountered

how to upload binary image to sql server using php laravel

Xdebug can't connect back to Docker host

args[max_input] woocommerce if statement confused

How can I make this nested location configuration use the correct path to call a php program?

enroll_table three field fetch to payment form to create payment field in laravel 5.5

Laravel database insert with combining array and string

Ajax GET request fails in laravel 8

Login if user is active using Laravel Breeze

OctoberCMS / Anonymous Global Scope

How do I enable error reporting in Laravel?

Laravel PHP: multiple project run at the same time [closed]

About Contact Privacy policy Terms and conditions