Current location: Hot Scripts Forums » Programming Languages » PHP » Same letter different order


Same letter different order

Reply
  #1 (permalink)  
Old 12-03-05, 02:49 PM
PSTUBb PSTUBb is offline
New Member
 
Join Date: Dec 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Same letters different order

How would I go about comparing two words to see if one has the same letters as the other, but not necessairily in the same order.
so it would be sort of but not exactly like
abcd = cbda would be true
but
abcd = abce would be false.
where the = sign would be whatever I use to compare them that way...

I hope you understand what I'm talking about!

Thank you!

Last edited by PSTUBb; 12-03-05 at 03:39 PM. Reason: Subscribing to thread
Reply With Quote
  #2 (permalink)  
Old 12-03-05, 03:55 PM
Keith's Avatar
Keith Keith is offline
Community Liaison
 
Join Date: Feb 2004
Posts: 1,232
Thanks: 1
Thanked 11 Times in 11 Posts
One way to accomplish this would be to split each word into an array, sort() both arrays, and implode() them back to a string. Then if they match, return true. Otherwise return false.

Last edited by Keith; 12-03-05 at 03:58 PM.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 06:22 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.