-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforeach.php
More file actions
64 lines (57 loc) · 1.33 KB
/
foreach.php
File metadata and controls
64 lines (57 loc) · 1.33 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
$things = array('Sgt. Pepper', "11", null, array(1,2,3), 3.14, "12 + 7", false, (string) 11);
// foreach($things as $thing) {
// if(is_int($thing)) {
// echo "$thing is an integer!";
// } elseif(is_float($thing)) {
// echo "$thing is a float!";
// } elseif(is_bool($thing)) {
// echo "$thing is a boolean!";
// } elseif(is_array($thing)) {
// print_r("$thing is an array!");
// } elseif(is_null($thing)) {
// echo "$thing is null!";
// } elseif(is_string($thing)) {
// echo "$thing is a string!";
// }
// echo PHP_EOL;
//}
// foreach($things as $thing) {
// if(is_int($thing)) {
// echo "Integer!";
// } elseif(is_float($thing)) {
// echo "Float!";
// } elseif(is_bool($thing)) {
// echo "Boolean!";
// } elseif(is_array($thing)) {
// print_r("Array!");
// } elseif(is_null($thing)) {
// echo "Null!";
// } elseif(is_string($thing)) {
// echo "String!";
// }
// echo PHP_EOL;
// }
// foreach($things as $thing) {
// if(is_scalar($thing)) {
// echo $thing;
// }
// echo PHP_EOL;
// }
foreach($things as $thing) {
if(is_int($thing)) {
echo $thing;
} elseif(is_float($thing)) {
echo $thing;
} elseif(is_bool($thing)) {
echo $thing;
} elseif(is_array($thing)) {
print_r($thing);
} elseif(is_null($thing)) {
echo $thing;
} elseif(is_string($thing)) {
echo $thing;
}
echo PHP_EOL;
}
?>