Users Pricing

forum

Home Forums How to add attribute in JSON in PHP? – MindStick

How to add attribute in JSON in PHP?

Kate Smith 4037 20 Jun 2013

I have Json in PHP like this:

$json = '{"total":"100", "page":"1", "records":"100", "rows": [ 
{"no":"1","part_number":"2","part_name":"3","price":"4","note":"8"}]}';

and I want to add

"test1":"5","test2":"7"
into JSON above.

so it will be like this:

$json = '{"total":"100", "page":"1", "records":"100", "rows": [ 
    {"no":"1","part_number":"2","part_name":"3","price":"4","test1":"5","test2":"7","note":"8"}]}';

Please, help me. How to add attribute in JSON in PHP?

1 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md