• 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

Encrypt in php and decrypt in Dart(flutter)

Reading input in php from terminal

No result using makeStyles Material UI in react 18

get data-value with variable value

Laravel Route issues with Route order in web.php

Uncaught TypeError: Cannot read property 'length' of null when retrieving tags from wp

PHP: How to quickly split a key=value file into associative array

How can I make Laravel return a custom error for a JSON REST API

Trying to iterate over a mongodb cursor twice - failing

Can't find vendor/autoload.php for Ratchet

MySQL default time format UTC or GMT?

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'posts.post' doesn't exist

Split comma separated value from table column into rows using mysql?

How to send image,audio or video through the WhatsApp API - PHP

How can I get a div content in php

About Contact Privacy policy Terms and conditions