Skip to content

Commit

Permalink
added Naive_Approach.php
Browse files Browse the repository at this point in the history
  • Loading branch information
MehakJain96 committed Jul 29, 2016
1 parent bf26d11 commit 67c4c2d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Naive_String_Matching/Naive_Approach.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

$str1 = "namanchamanbomanamansanam";
$str2 = "aman";

$len1 = strlen($str1);
$len2 = strlen($str2);

for($i = 0; $i <= $len1 - $len2; $i++)
{
for($j = 0; $j < $len2; $j++)
if($str1[$i + $j] != $str2[$j])
break;

if($j == $len2)
echo "Pattern Found at ".($i+1)."<br>" ;
}
?>

0 comments on commit 67c4c2d

Please sign in to comment.