Re: STUCK : String Comaparison

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Ron,

Also in PHP a string is actually an array of characters. Maybe you can pick 
out each character and compared it to the character in the same position of 
the known string! 
Example:
// Get the first character of a string
$str = 'This is a test.';
$first = $str{0};

// Get the third character of a string
$third = $str{2};

Cheers, RICO

On Thursday 01 April 2004 14:59, Ron.Herhuth@xxxxxxxxxxxxxxxxx wrote:
> 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

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux