• 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

sort() not affecting original array while inside foreach loop

Check if a string contain multiple specific words

Dynamic dropdown Ajax PHP request

Dynamic dropdown Ajax PHP request

yii2 and mssql insert varbinary into model

Mysqli multi query error

How to Display Data in Yajra Datatables Laravel 7?

How to convert the int value to inch in PHP [closed]

jQuery Ajax Post with data

How do I upload a laravel project on cPanel shared hosting?

How to read laravel_session cookies saved in cookie memory of browser in client side?

Yii2: How to download backup files using spanjeta/yii2-backup?

Laravel excel maatwebsite 3.1 import, date column in excel cell returns as unknown format number. How to solve this?

How can i call a function that executes an fpdf based on the choice of a form selector?

display WooCommerce “Add to cart” button with short-code [add_to_cart ] dynamically

About Contact Privacy policy Terms and conditions