Jump to content

PHP REGEX


cry of war

Recommended Posts

The regex for this isnt working right for some reason and i cant figure out why. I dont think this is regex but maybe something wrong with my array skills

 

 


echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">";
echo "<textarea name=\"info\" COLS=30 ROWS=30></textarea><br>\n";
echo "<input type=\"TEXT\" value=\"ID\" name=\"ID\">";
echo "<input type=\"RADIO\" value=\"MAIN SPY\" name=\"ID\">";
echo "<input type=\"submit\" value=\"Submit\" name=\"submit\">";
echo "</form>";if (isset($_POST["submit"])) {
$find = array('Mercenaries', 'Jaffa Army', 'Super Soldiers', 'Drones', 'Clones', 'bot', 'Units', 'Human Form troop7', 'Soldier', 'NID Agent', 'Army', '  ', ',', '');
$replace = array('troop1','troop2','troop3','troop2','troop3','troop2','troop3','troop2','troop3','troop2','troop3', ' ', '');
$info=$_POST["info"];
$info = str_replace($find, $replace, $info);
$a = explode("\r\n", $info);
/*
This is what info would be some-what equal to
$info="recon Mission Report
Under the cover of night, your 1,210,000 Covert Agents sneak into the realm of blah . 
Your Covert Agents move stealthily through the lands of drippytaco undetected. They are able to gather many documents recording the status of weapons, army size and preparedness, and fortifications. 
";
*/

foreach ($a[0] as $v) {
/*Main*/
/*Main Name*/
$pattern="/Under the cover of night your .* Covert Agents sneak into the realm of (.*)\./";
if (preg_match($pattern, $v)==true)
{
Echo "match found.";
/* $v[0] should="blah" Right? */
}
else
{
Echo "No match found.";
}
}

But anyways even with that else command it still shows a blank screen after the and doesnt display the match found or No match found. Or is there a Maybe. Maybe there was a match-maybe there wasnt?

Link to comment
https://forums.phpfreaks.com/topic/96906-php-regex/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.