Re: STUCK : String Comaparison
| From: | DvDmanDT | Date: | Thu, 01 Apr 2004 17:07:26 +0000 |
| Subject: | Re: STUCK : String Comaparison | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-23338@lists.php.net to get a copy of this message | ||
Umm..
$static=bindec('10100000');
$dynamic=bindec('10110000');
# Can't think right now, but it seems like
# you can just do this instead: $dynamic & ~$static
if(($static|$dynamic)& ~$static)
{
# Don't throw flag
}
else
{
# Throw flag
}
It throws a flag, if all 1's in the dynamic string has a match in the static
one, but not if the static one has a 1 that the other doesn't have..
Correct?
--
// DvDmanDT
MSN: dvdmandt¤hotmail.com
Mail: dvdmandt¤telia.com
"Ron Herhuth" <Ron.Herhuth@tatumpartners.com> skrev i meddelandet
news:b46c01c417e9$334b05b0$f25d2981@tatumlink.com...
I may be just over thinking this but I'm stuck trying to figure out a
solution that has to deal with comparing a series of dynamic strings to a
known string. The strings will be 8 characters long and each character
will be either a zero or a 1. What I need to do is to compare the dynamic
strings with the known and if each of the 1 characters in the dynamic
string aligns with the 1 characters in the known string it will throw a
flag. The dynamic string does NOT need to contain all of the 1 characters
that the known string does, just that the ones that it contains align.
Examples:
Known:
10100010
Dynamic:
00100000 Throws flag because both strings contain a 1 in position 3
01100000 Doesn't throw flag because there is a 1 in position 2
10100000 Throws a flag because the 1s in position 1 and 3 align
10110000 Doesn't throw a flag because of the 1 in position 4
I was able to create a function that matches the entire string but I lost
it when trying to deal with partial matches. Does anyone have a potential
solution for such a beast? I appreciate any input you might be able to
offer...
Thanks,
Ron