I have tried multiple codes in PHP to remove an element from an array of strings by their name. There are already two days of infinite searches on the web, without any solution.
The string json:
["stringNumero1","stringNumero2","stringNumero3","stringNumero4","stringNumero5"]
The PHP code:
$index = array_search("stringNumero3", $jsonDecodificado);
if($index !== FALSE){
unset($jsonDecodificado[$index]);
}
echo json_encode($jsonDecodificado);
Result in:
{0:"stringNumero1",1:"stringNumero2",2:"stringNumero3",3:"stringNumero4",4:"stringNumero5}
PS:
The variable $jsondecodificado
has as value json_decode(file_get_contents('rutaAlJson'), true)
Later I tried removing the second parameter true
of json_decode()
but it still did not give the expected result, the removal of the string "stringNumero3" within the array of strings.
Thanks for your answers.