Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how find the difference in string vars? 1

Status
Not open for further replies.

AlbertAguirre

Programmer
Nov 21, 2001
273
US
$basestr="this is a test of the emergency broadcast system"
$otherstrg="this is not a test of the urgent broadcast system"

I just want to compare $otherstr to the $basestr, not the other way around.

The difference in $otherstr is:
"not" and "urgent"

possible?
 
You could use eregi() looking for specific terms
then use preg_replace() to modif the str
 
Differences would be random. Would not know what to search for.
Dont want to modify just identify differences.
 
Is there anything fixed?
if so read str, search and rem the known segments.
the left should be = to rand
 

it may be possible to use array_diff to do what you need as well

Code:
<?
$string1 = "The quick brown fox jumps over the lazy black dog";
$string2 = "The quick brown chicken jumps over lazy black dog";

$a1 = explode (" ", $string1);
$a2 = explode (" ", $string2);

$result = array_diff($a1, $a2);

print_r ($result);
?>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top