Re: determine which string is longer and then what is different in that string

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

 



At 11:11 PM -0700 8/25/07, Richard Kurth wrote:

I am trying to find out which string is the longest and then find out what
is different between the two string. Sometimes String 2 is longer than
String 1 The script below works sometimes but not all the time.
Is there a better way to do this or tell me what is wrong with the script I
am using

$string1 = "1,2,3,4,5,6,7,8";
$string2 = "1,2,3,4,6,7,8";


Can you give us an example of two strings where the comparison fails? I suspect you are looking for the number of "entries" in the string, rather than the length of the string. For example:
$string1 = "1,2,3,4,5,6,9";
$string2 = "1,2,3,10,11,12";

number of entries in $string1 is 7, number of entries in $string2 is 6, but length($string1) = 13, while length($string2) = 14. Is this the problem you are seeing?

     -----===== Bill =====-----


--

The greatest calamity is not to have failed,
but to have failed to try.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux