-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathPHP-JSON-Array-cevirme.php
More file actions
36 lines (30 loc) · 1.09 KB
/
PHP-JSON-Array-cevirme.php
File metadata and controls
36 lines (30 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
// JSON kodlarını Array'a çevirme
$l = "https://www.instagram.com/ugur2nd/?__a=1";
function l($a){
$ch = curl_init();
$header = array();
$header[] = "Accept-Language: tr-tr,en;q=0.5";
curl_setopt_array($ch, [
CURLOPT_URL => $a,
CURLOPT_USERAGENT => "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTPHEADER => $header,
CURLOPT_AUTOREFERER => true
]);
$source = curl_exec($ch);
curl_close($ch);
return $source;
}
$l = l($l);
// Convert JSON string to Array
$someArray = json_decode($l, true);
print_r($someArray); // Dump all data of the Array
echo $someArray[0]["name"]; // Access Array data
// Convert JSON string to Object
$someObject = json_decode($l);
print_r($someObject); // Dump all data of the Object
echo $someObject[0]->name; // Access Object data