php /preg_match_all().php

Language PHP Lines 26
MD5 Hash c04903d33e226f0c5ad8890cf12b1c73
Repository https://github.com/choi3961/php.git View Raw File View Project SPDX
 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
<?php
$string = "/brown fox jumped [0-9]/";

$paragraph = "The brown fox jumped 1 time over the fence. The green fox did not. Then the brown fox jumped 2 times over the fence";

if (preg_match_all($string, $paragraph, &$matches)) {
  echo count($matches[0]) . " matches found";
}else {
  echo "match NOT found";
}
?>



//echo "position:$pos<br>";
/*******************************
$string = "/'/";
preg_match_all($string, $str,$matches);
$num = count($matches[0]);
//echo $num."<br>";
if($num>1){

echo "matches 2 above<br>";
echo $str."<br>";		
}
*********************************/
Back to Top