forked from gabyya/json
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
53 lines (50 loc) · 1.12 KB
/
index.php
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
$dogs = array(
array(
"Name" => "Bozo",
"Breed" => "Pug",
"Speed" => "Slow",
"Meals" => 3
),
array(
"Name" => "Butters",
"Breed" => "Mutt",
"Speed" => "Fast",
"Meals" => 2
),
array(
"Name" => "Homie",
"Breed" => "Sheep Dog",
"Speed" => "Slow",
"Meals" => 9
),
array(
"Name" => "Sydno",
"Breed" => "Border Collie",
"Speed" => "Fast",
"Meals" => 3
)
);
$json_dogs = json_encode($dogs, JSON_PRETTY_PRINT);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>JSON</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
</head>
<body>
<div class="container py-5">
<h2>
<?php echo $dogs[3]["Breed"]; ?>
</h2>
<pre>
<?php //echo $json_dogs; ?>
</pre>
<pre>
<?php //print_r(json_decode($json_dogs, true)); ?>
</pre>
</div>
</body>
</html>