XpertWorlock Posted May 19, 2009 Share Posted May 19, 2009 Hi, I have a string with a length of 5, I need it to only contain 4,5,6,7,9. [45679]{5} This works perfect in that aspect. Now I need it to only contain each number once. Example: 97654, good 44459, bad 45679, good 66759, bad Thanks a lot Link to comment https://forums.phpfreaks.com/topic/158765-solved-only-one-of-each-number/ Share on other sites More sharing options...
Ken2k7 Posted May 19, 2009 Share Posted May 19, 2009 Quick play function blah ($num) { $str = strval($num); $arr = str_split($str); $unique = array_unique($arr); return sizeof($arr) === sizeof($unique); } Link to comment https://forums.phpfreaks.com/topic/158765-solved-only-one-of-each-number/#findComment-837359 Share on other sites More sharing options...
XpertWorlock Posted May 19, 2009 Author Share Posted May 19, 2009 that works Awesome thanks couldn't find it anywhere else Link to comment https://forums.phpfreaks.com/topic/158765-solved-only-one-of-each-number/#findComment-837365 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.