0
Hello, good afternoon. How can I make a foreach loop or a preg_match_all to count the amount in that element appid repeats in a page ?
I tried this way and got:
function get_Jogos() {
$array = [ ["appid" => 291550,"name" => "Brawlhalla"], ["appid" => 000000,"name" => "Teste"], ["appid" => 000023,"name" => "Teste2"], ];
foreach($array as $arr)
if (array_key_exists("appid", $arr))
echo $jogos = $arr["name"] . "<br>";
}
get_Jogos();
New doubt:
How to check the existence of the string "appid" on a page after a Curl and so make the listing of the names of "games" ?
curl_setopt($ch, CURLOPT_URL , "https://steamcommunity.com/profiles/$steamid/games/?tab=all");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$resp = curl_exec($ch);
Sabrina, try this:
$count = count(array_keys($array, 'appid', true));
and then:echo $count;
to see if it displays the result.– Rodrigo Tognin
It’s in PHP or Javascript!?
– rbz
I tried this way:
$array = [
["appid" => 291550,"name" => "Brawlhalla"],
["appid" => 000000,"name" => "Teste"],
];

$count = count(array_keys($array, 'appid', true));
echo $count;
The return is: 0. It’s in php– SABRINA FUTUROSO
I haven’t been able to.
– SABRINA FUTUROSO