Skip to content
Open
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
20c72a8
Code challenge part 1
IzzyD7 May 18, 2016
e6ec86c
Code Challenge2
IzzyD7 May 18, 2016
b8ded87
Code Challenge 3
IzzyD7 May 18, 2016
d498a70
Attempt Arrays
IzzyD7 May 22, 2016
5d1c81c
code challenge 5
IzzyD7 May 23, 2016
6ea60aa
code challenge 6
IzzyD7 May 23, 2016
eee5287
Travis Attempt #2
IzzyD7 May 23, 2016
c80cf9c
Travis Attempt #3
IzzyD7 May 23, 2016
f9e1b8e
test
IzzyD7 May 24, 2016
b946b2c
Travis Attempt #4
IzzyD7 May 24, 2016
bb2858d
Travis Attempt #5
IzzyD7 May 24, 2016
191f84c
Travis Attempt #6
IzzyD7 May 24, 2016
20c19a6
Travis Attempt #6a
IzzyD7 May 24, 2016
c0b1686
Travis Attempt #6b
IzzyD7 May 25, 2016
3945773
Travis Attempt #7
IzzyD7 May 25, 2016
9780df8
Travis Attempt #8
IzzyD7 May 25, 2016
48d6665
Travis Attempt #9
IzzyD7 May 25, 2016
15b7cd3
Travis Attempt #9a
IzzyD7 May 25, 2016
3435b92
Travis Attempt #10
IzzyD7 May 25, 2016
e8b00ed
Travis Attempt #11
IzzyD7 May 25, 2016
a684d76
travis Attempt #12
IzzyD7 May 26, 2016
13d08d4
Travis Attempt #13
IzzyD7 May 26, 2016
9c74752
Travis Attempt #14
IzzyD7 May 26, 2016
0291e32
Travis Attempt #14b
IzzyD7 May 26, 2016
ac5df4a
Travis Attempt #15
IzzyD7 May 26, 2016
02ac45c
Travis Attempt #16
IzzyD7 May 26, 2016
4e2b627
Travis Attempt #17
IzzyD7 May 26, 2016
07aae06
Travis Attempt #18
IzzyD7 May 26, 2016
6ffdccf
Travis Attempt #19
IzzyD7 May 26, 2016
ea38d6e
Travis Attempt #20
IzzyD7 May 26, 2016
dbbef10
Travis Attempt #21
IzzyD7 May 26, 2016
57d6123
Travis Attempt #22
IzzyD7 May 31, 2016
442f50e
Travis Attempts #21a
IzzyD7 May 31, 2016
34e38ea
Travis Attempt #22
IzzyD7 May 31, 2016
306d5b8
Travis Attempt #23
IzzyD7 May 31, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions src/data_types.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<?php
//convert_to_int
function convert_to_int($int){
$value = intval($int);
if ($value) {
return $value;
} else {
return 0;
}
}
echo convert_to_int("Hold The DOOR!");


//convert_to_float
function convert_to_float($float){
$convert = floatval($float);
if($convert) {
return $convert;
} else {
return 0.0;
}
}
echo convert_to_float("pop");


//convert_to_string
function convert_to_string($string){
if(is_integer($string) || is_string($string) || is_float($string)){
return strval($string);
} elseif (is_array($string)) {
return implode(", ", $string);
} else {
$empty = '';
return $empty;
}
}
echo convert_to_string(["skate",45,"trap"]);


//convert_to_bool
function convert_to_bool($bool){
if(boolval($bool) == 1) {
return true;
} else {
return false;
}
}
echo convert_to_bool(798);


// //convert_to_array
// function convert_to_array($arr){
// if(is_array($arr)) {
// $test = array_values($arr);
// print_r($test);
// }
// elseif (is_int($arr) || is_string($arr) || is_float($arr) || is_bool($arr)) {
// $convert_arr = array($arr);
// print_r(array_values($convert_arr));
// } else {
// if (!$arr == null) {
// $empty = [];
// print_r($empty);
// } else
// print_r(null);
// var_dump($empty);
// }
// }

// echo convert_to_array(45);


//convert_to_array
function convert_to_array($arr){
if (is_array($arr)) {
return $arr;
} elseif (is_int($arr) || is_string($arr) || is_float($arr)) {
$convert_arr = array($arr);
var_dump($convert_arr);
return array_values($convert_arr);
} else {
$nothing = [];
return $nothing;
}

}

return convert_to_array(null);












//convert_to_null
function convert_to_null($null){
if (!$null || $null === "null") {
return null;
} else {
return $null;
}
}
$test = convert_to_null("null");
var_dump($test);