From a92dddee9cc2d2307ca6fc4dd43a475fe8a69b44 Mon Sep 17 00:00:00 2001 From: Stephen Wright Date: Tue, 20 Sep 2016 19:23:47 -0400 Subject: [PATCH 1/8] Fixed? --- src/string_search.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/string_search.php diff --git a/src/string_search.php b/src/string_search.php new file mode 100644 index 0000000..c4cbb74 --- /dev/null +++ b/src/string_search.php @@ -0,0 +1,36 @@ + From 9ab669797d762d79f011ba16fbd9db6faf48bb5e Mon Sep 17 00:00:00 2001 From: Stephen Wright Date: Tue, 20 Sep 2016 19:35:54 -0400 Subject: [PATCH 2/8] new --- src/string_search.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/string_search.php b/src/string_search.php index c4cbb74..24f1d88 100644 --- a/src/string_search.php +++ b/src/string_search.php @@ -1,6 +1,6 @@ Date: Tue, 20 Sep 2016 19:38:26 -0400 Subject: [PATCH 3/8] ok --- src/string_search.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/string_search.php b/src/string_search.php index 24f1d88..0e043be 100644 --- a/src/string_search.php +++ b/src/string_search.php @@ -10,7 +10,7 @@ function string_search($needle,$haystack){ echo " and exists at position $pos"; } } -string_search($needle,$haystack); +#string_search($needle,$haystack); # String Search #For this PHP code exercise, create a file named `string_search.php`. This file should contain From 840b85d6a7dbedb23fbf9e5e3f21530e7523f864 Mon Sep 17 00:00:00 2001 From: Stephen Wright Date: Tue, 20 Sep 2016 19:48:40 -0400 Subject: [PATCH 4/8] ? --- src/string_search.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/string_search.php b/src/string_search.php index 0e043be..8b3efcf 100644 --- a/src/string_search.php +++ b/src/string_search.php @@ -4,10 +4,12 @@ function string_search($needle,$haystack){ $pos = strpos($haystack, $needle); if ($pos === false) { - echo "The string '$needle' was not found in the string '$haystack'"; + return false#return false echo "The string '$needle' was not found in the string '$haystack'"; } else { - echo "The string '$needle' was found in the string '$haystack'"; - echo " and exists at position $pos"; + return `Found '$needle' at index $pos` + + # return echo "The string '$needle' was found in the string '$haystack'"; + # return echo " and exists at position $pos"; } } #string_search($needle,$haystack); From ee0d9db568dc6a53bce32ef7297d35b7a6d2de86 Mon Sep 17 00:00:00 2001 From: Stephen Wright Date: Tue, 27 Sep 2016 11:55:31 -0400 Subject: [PATCH 5/8] d --- src/string_search.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/string_search.php b/src/string_search.php index 8b3efcf..479dcab 100644 --- a/src/string_search.php +++ b/src/string_search.php @@ -4,9 +4,10 @@ function string_search($needle,$haystack){ $pos = strpos($haystack, $needle); if ($pos === false) { - return false#return false echo "The string '$needle' was not found in the string '$haystack'"; - } else { - return `Found '$needle' at index $pos` + return false;#return false echo "The string '$needle' was not found in the string '$haystack'"; + } + else { + return `Found '$needle' at index $pos`; # return echo "The string '$needle' was found in the string '$haystack'"; # return echo " and exists at position $pos"; From 6fa0024c841882389fba7eb85c90473c6b5da519 Mon Sep 17 00:00:00 2001 From: Stephen Wright Date: Tue, 27 Sep 2016 12:02:33 -0400 Subject: [PATCH 6/8] fix quote --- src/string_search.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/string_search.php b/src/string_search.php index 479dcab..c400b1a 100644 --- a/src/string_search.php +++ b/src/string_search.php @@ -4,10 +4,10 @@ function string_search($needle,$haystack){ $pos = strpos($haystack, $needle); if ($pos === false) { - return false;#return false echo "The string '$needle' was not found in the string '$haystack'"; + return false; #return false echo "The string '$needle' was not found in the string '$haystack'"; } else { - return `Found '$needle' at index $pos`; + return "Found '$needle' at index $pos"; # return echo "The string '$needle' was found in the string '$haystack'"; # return echo " and exists at position $pos"; From 129219f4082b9f313cf60b1fb3467ee65f521d79 Mon Sep 17 00:00:00 2001 From: Stephen Wright Date: Tue, 27 Sep 2016 12:08:29 -0400 Subject: [PATCH 7/8] fix needle is false? --- src/string_search.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/string_search.php b/src/string_search.php index c400b1a..486f2bb 100644 --- a/src/string_search.php +++ b/src/string_search.php @@ -2,6 +2,10 @@ #$haystack = 'string search'; #$needle = 'search'; function string_search($needle,$haystack){ + if ($needle === false){ + return false; + } + else{ $pos = strpos($haystack, $needle); if ($pos === false) { return false; #return false echo "The string '$needle' was not found in the string '$haystack'"; @@ -12,6 +16,7 @@ function string_search($needle,$haystack){ # return echo "The string '$needle' was found in the string '$haystack'"; # return echo " and exists at position $pos"; } + } } #string_search($needle,$haystack); # String Search From fcf898e5347f8379fc7cb9743685731a18545fe5 Mon Sep 17 00:00:00 2001 From: Stephen Wright Date: Tue, 27 Sep 2016 12:11:44 -0400 Subject: [PATCH 8/8] read --- src/string_search.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/string_search.php b/src/string_search.php index 486f2bb..554501e 100644 --- a/src/string_search.php +++ b/src/string_search.php @@ -2,7 +2,7 @@ #$haystack = 'string search'; #$needle = 'search'; function string_search($needle,$haystack){ - if ($needle === false){ + if ($needle == ''){ return false; } else{