• 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

array_map triple dimensional array [duplicate]

WordPress Security Standards want me to escape my html, but how to do it correctly?

(PHPUnit) PHP Fatal error: Uncaught Error: Call to undefined function each()

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

WooCommerce: Add/display Product or Variation custom field everywhere

Laravel Command Schedule Not Working Properly

How to run a shell as root from php (apache)

Combining a describing and one array with data

Detect a fetch request in PHP

How to fix this error : Ask your hosting provider to use PHP 7.2.5 or higher for both HTTP and CLI?

How to get multiple values with same key from an array PHP

loop through an anchor id

Facebook API, get page post link (PHP)

dockerizing Laravel + vue

Json_Encode not returning html even i try to encode JSON_HEX_QUOT | JSON_HEX_TAG

About Contact Privacy policy Terms and conditions