• 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

curl returning 301 error after migrating to https

Destroy session upon refresh

The difference when using if statement true === something() vs something() === true [duplicate]

How can I get a div content in php

Laravel 5.1 xmlHttpRequest AJAX POST TokenMismatchException

Laravel Pagination links() not working

Transpose multidimensional array and join values with commas

Codeigniter, Severity: error --> Exception: Too few arguments to function, admin dashboard shows HTTP error 500

JSON Render Issue in Date Object Laravel and PHP 7.4

How can I create a Download Page with post php method?

Laravel 5 session not persisting after user is logged in

Creating a config file in PHP

How to edit Records using CodeIgniter

Why isn't my PHP exception working?

Clear javascript source cache laravel 5.8

About Contact Privacy policy Terms and conditions