• 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 create custom authentication in laravel 8?

Return new collection without modifying original collection

How to update array value in Laravel

how to prevent float variables displaying as scientific notation when printing [duplicate]

Pass an image through AJAX [duplicate]

"Unable to load dynamic library 'pdo_sqlsrv.so' "Cenos7 PHP7.2.10

How to get AJAX to post on second page?

CSV to PHP class properties

How to set a domain name with php artisan serve

Warning file_get_contents () failed to open stream: HTTP request failed! HTTP/1.0 402 Payment Required

Ajax GET request fails in laravel 8

How to add automatically collapse/expand in content wordpress (single.php)?

Center point of multiple gps coordinates with php

How to generate QR CODE for dynamic generating link and logo using Simple QrCode in laravel?

How to access a var with "-" in PHP [duplicate]

About Contact Privacy policy Terms and conditions