• 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

Object of class stdClass could not be converted to string error

If you intend you use SMTP, add your SMTP Code after this Line

Is there a way to use Foundry Model for Authentification inside Functional Tests?

SQLSTATE[HY000]: General error: 1 table posts has no column named *

SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: 'column_name' in Laravel

Facebook API, get page post link (PHP)

Is it possible to change the table name in the migration file-laravel

get folder directory from input type file - PHP

Edit XML in HTML form and submit to self

How to find phpcs current default standard

How to install PHP composer inside a docker container

Laravel/ PHP: Order By Alphabetical with numbers in order [duplicate]

Call authenticate manually in router middleware

Failing validation doesn't stop code execution in livewire component

Laravel 5.1 Unknown database type enum requested

About Contact Privacy policy Terms and conditions