-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path9.php
More file actions
27 lines (27 loc) · 975 Bytes
/
Copy path9.php
File metadata and controls
27 lines (27 loc) · 975 Bytes
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
<?php
header('Content-Type: text/plain');
$states=array("Mississippi","Alabama","Texas","Massachusetts","Kansas");
$statesArray=[];
foreach($states as $s){
if(preg_match('/xas$/',($s))){
$statesArray[0] = ($s);
echo "\nThe States that ends in xas:".$s;
echo "\n $s is at position 0";
}
if(preg_match('/^k.*s$/i', ($s))){ // i for case insensitive
$statesArray[1] = ($s);
echo "\nThe states that begins with k and ends in s:" . $s;
echo "\n $s is at position 1";
}
if(preg_match('/^M.*s$/', ($s))){
$statesArray[2] = ($s);
echo "\nThe states that begins with M and ends in s:" . $s;
echo "\n $s is at position 2";
}
if(preg_match('/a$/', ($s))){
$statesArray[3] = ($s);
echo "\nThe states that ends in a:".$s;
echo "\n $s is at position 3";
}
}
?>