• 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

Transpose and flatten multiple rows of array data [duplicate]

Mobile browsers are adding .html to filename on download

Laravel Route issues with Route order in web.php

merging two arrays with specified index

How to add a sidebar to Woocommerce Shop Page?

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

How to convert a carbon into string, to take the date only?

How to display table header in every page using FPDF library?

Pass an image through AJAX [duplicate]

Update Total in checkout of Woocommerce with Ajax Request

Access denied for user 'homestead'@'localhost' (using password: YES)

Symfony redirect if already loggedin from login page

PHP-Sort array based on another array?

Appending data to an anchor tag

hidden INPUT value not available in $_POST

About Contact Privacy policy Terms and conditions