• 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

Check for PDO Results, If None Display Message, If Yes then Loop Through

Artisan, creating tables in database

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

PHP - CURL using HTTPS [closed]

could not find driver Debian SQL Server PHP

How to fix Call to undefined method AppModelsTableName::factory?

PHP using str_starts_with for array to exclude same as with wildcard

Laravel - Browser displays message again when I press back button

Parameter is not sent to Laravel route in Ajax

How in Laravel run JavaScript code stored in php variable?

Laravel multi auth - Authentication user provider [] is not defined

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource [duplicate]

mysql slow on updates for a well optimized query

Center point of multiple gps coordinates with php

Popup Window and PHP form

About Contact Privacy policy Terms and conditions