The reason why I asked this array or object, is because I used echo is_array($news) ? 'Array' : 'not an Array'; and it showed it's not an array, is it an object then.
I know how to read from a php array. I basically have a formdata like this search array look like this
searcharray = ["yemen", "america", "franc", "germany"];
const json = JSON.stringify({searcharray });
const formData = new FormData();
formData.append('searcharray', json);
formData.append('news', 'true');
then when I recieve it on php I do this
if (isset($_POST["news"]) )
{
$searcharrayx = $_POST["searcharray"];
$object = json_decode(json_encode($searcharrayx), FALSE);
echo is_array($object) ? 'Array' : 'not an Array';
// I tried this didn't work
$firstvalue = reset($object);
echo $firstvalue;
//I tried var dump that didn't work either get an error
//I tried object[0] I just get the first chracter {
Baisically what I want to do, is add this to a text like this
["yemen", "america", "france", "germany"];
$string = "yemen&america&france&germany"; in php
I'm sorry if this was asked too many times, I checked for the past two hours stackoverflow it solved one problem, it's just because I'm not advanced in php or I'm dumb, I can easily solve this however in js. I'm still searching if I find an answer, I'll update it.
Update I found a solution, which I used before for hours it didn't work now it works, I didn't change anything on the frontend. I just did
I changed only the naming variables.
if (isset($_POST["news"]) )
{
$searcharrayx = $_POST["searcharray"];
$b = $searcharrayx;
//echo $b;
$a = json_decode($b, true); //this one now works for some reason
$ccount = count($a);
$e = "";
for($d = 0; $d<=$ccount+-1; $d++) {
if($d == $ccount +-1){
$e = $e.$a[$d];
} else {
$e=$e.$a[$d]."%20AND%20";
}
}