Change the Value of json with PHP


I have a json file where I am listing the information that I am interested with with PHP.

I'm using Lottie.js to run this .json as a gif/video, my idea is to change the messages from English to Portuguese, I'm able to list them from json, but I don't know how to change it, follow my code:

$url = 'js/data3.json';

$jsonStr = file_get_contents($url);
$jsonArr = json_decode($jsonStr, true);

$titulo = array();

foreach ($jsonArr['layers'] as $row) {

$titulo[] = $row['nm'];


the result I'm getting is:

Keep an eye out for an email 
Message sent
Send Message

(is bringing the texts)

How do I change the Message sent value per Mensagem enviada for example?

Json Link:


My first interaction with JSON with PHP, I had already done something a little more complex with XML, but the idea is the same, the functions that change:

I saved the json in a .JSON file in the same folder as the PHP file.

//abrindo o json externo
$json = json_decode(file_get_contents('teste.json'));

//Editando a linha que vc quer
$json->layers[1]->nm = "Mensagem Enviada";

//Salvando as edições
$json_editado = file_put_contents('teste.json',json_encode($json));

//Carregando json após ser salvo já editado
$json = json_decode(file_get_contents('teste.json'));
//Imprimindo json editado

What can mess up a little is that part of json has an Array, and it can mess up a little when it comes to the attribute or object.

Scroll to Top