• 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

Symfony 4: how to allow dynamic values for array nodes in bundle configuration?

Updating and Synchronizing Woocommerce Subscriptions to Custom Date

How do I set the maximum php memory limit

Redirect to previous page with php

enable Apache http Authorization header

how to use extended ASCII instead of unicode in PHP

Target class controller does not exist - Laravel 8

Doctrine ORM: Excluding Records Based on Values of Nested Relationships

Laravel UUID generation

Laravel s3 upload file with metadata using pre-signed url

"Mixed content blocked" when running an HTTP AJAX operation in an HTTPS page

PHP Print to Network Printer

How to add class name to an existing tag in php

The "client_reference_id" argument is not passed

How do I loop through an MS SQL database with VB.NET?

About Contact Privacy policy Terms and conditions