• 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 can I make Laravel return a custom error for a JSON REST API

Backend cannot be reached after Typo3 login screen

How to convert binary string to normal string in php

How to submit a form when page loads using JavaScript?

How to execute sql code based on fetch array

correct PHP headers for pdf file download

Detect emoticons in string

IlluminateDatabaseQueryException could not find driver [duplicate]

Batch request Google Calendar php API

Laravel/docker-compose/redis - Class 'Redis' not found

Clear javascript source cache laravel 5.8

Docker & Laravel : configure: error: Package requirements (oniguruma) were not met

Jquery DataTables: Data not displaying in table via Ajax

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

auth pages not getting css in laravel

About Contact Privacy policy Terms and conditions