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

From: Date: Sun, 26 Aug 2007 22:05:00 +0000
Subject: Re: determine which string is longer and then what is different in that string
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-261307@lists.php.net to get a copy of this message
On Sun, August 26, 2007 1:11 am, 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"; I didn't follow your code, but I think your answer lies in here somewhere: $array1 = explode(',', $string1); $array2 = explode(',', $string2); $diff1 = array_diff($array1, $array2); $diff2 = array_diff($array2, $array1); $diff = array_merge($diff1, $diff2); var_dump($diff1); var_dump($diff2); var_dump($diff); -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So?

« previous php.general (#261307) next »