• 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 to get AJAX to post on second page?

array_key_exists(): The first argument should be either a string or an integer

Google API Heatmap Layer exception, why?

Utf8 encoding issue with Laravel

Doctrine 2 mapping referencing unique key

Laravel + phpunit + github actions = Failed asserting that '1' is identical to 1

How to fix bootstrap multiselect search data using ajax

Composer Warning: openssl extension is missing. How to enable in WAMP

Parameter is not sent to Laravel route in Ajax

Laravel MSSQL Server Connection not working

Unit (real unit test) of test laravel relationship

Magento Installation SQLSTATE[HY000] [2002] No such file or directory error

CONCAT columns with Laravel 5 eloquent

How to write PHP in XSLT

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'posts.post' doesn't exist

About Contact Privacy policy Terms and conditions