c_pattle Posted November 18, 2010 Share Posted November 18, 2010 I need to write a function which comes two strings to find out if string 1 is an anagram or a palindrome For example the function should return 1 for the argument "dooernedeevrvn", because it is an anagram of a palindrome "neveroddoreven". For argument "aabcba", your function should return 0. I'm not really sure where to start so if anyone has done anything similar then any help would be great. Thanks for any help. Link to comment https://forums.phpfreaks.com/topic/219135-anagram-of-a-palindrome-function/ Share on other sites More sharing options...
Rifts Posted November 18, 2010 Share Posted November 18, 2010 hey my favorite palindrome is "No garden one dragon" Link to comment https://forums.phpfreaks.com/topic/219135-anagram-of-a-palindrome-function/#findComment-1136379 Share on other sites More sharing options...
Pikachu2000 Posted November 18, 2010 Share Posted November 18, 2010 Does the function also need to determine whether the second parameter is actually a palindrome or not? Link to comment https://forums.phpfreaks.com/topic/219135-anagram-of-a-palindrome-function/#findComment-1136380 Share on other sites More sharing options...
c_pattle Posted November 18, 2010 Author Share Posted November 18, 2010 sorry I made a mistake, the function will just take one string and it just needs to work out if this is an anagram of any palindrome. Link to comment https://forums.phpfreaks.com/topic/219135-anagram-of-a-palindrome-function/#findComment-1136381 Share on other sites More sharing options...
simshaun Posted November 18, 2010 Share Posted November 18, 2010 function is_palindrome($str) { return $str == strrev($str); } Link to comment https://forums.phpfreaks.com/topic/219135-anagram-of-a-palindrome-function/#findComment-1136384 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.