dezkit Posted December 6, 2008 Share Posted December 6, 2008 Is it possible for php to echo all the possible combinations of 2 lettered words? as in A1, A2, A3, A4, A5, A6, A7, A8, A9, A0, etc If so, how can i do this? Link to comment https://forums.phpfreaks.com/topic/135845-solved-combinations/ Share on other sites More sharing options...
premiso Posted December 6, 2008 Share Posted December 6, 2008 $alpha = "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"; $alphaArray = split(" ", $alha); foreach ($alphaArray as $alpha) { foreach ($alphaArray as $alpha2) { echo $alpha . $alpha2 ", "; } } Link to comment https://forums.phpfreaks.com/topic/135845-solved-combinations/#findComment-708112 Share on other sites More sharing options...
dezkit Posted December 6, 2008 Author Share Posted December 6, 2008 Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /home/cobi/public_html/testtt.php on line 8 <?php $alpha = "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"; $alphaArray = split(" ", $alha); foreach ($alphaArray as $alpha) { foreach ($alphaArray as $alpha2) { echo $alpha . $alpha2 ", "; // line 8 } } ?> line 8 Link to comment https://forums.phpfreaks.com/topic/135845-solved-combinations/#findComment-708115 Share on other sites More sharing options...
dezkit Posted December 6, 2008 Author Share Posted December 6, 2008 Nevermind, i fixed it, but it shows nothing but a comma on my page <?php $alpha = "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"; $alphaArray = split(" ", $alha); foreach ($alphaArray as $alpha) { foreach ($alphaArray as $alpha2) { echo $alpha . $alpha2 . ", "; } } ?> Link to comment https://forums.phpfreaks.com/topic/135845-solved-combinations/#findComment-708118 Share on other sites More sharing options...
premiso Posted December 6, 2008 Share Posted December 6, 2008 Nevermind, i fixed it, but it shows nothing but a comma on my page <?php $alpha = "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"; $alphaArray = split(" ", $alha); foreach ($alphaArray as $alpha) { foreach ($alphaArray as $alpha2) { echo $alpha . $alpha2 . ", "; } } ?> <?php $alpha = "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"; $alphaArray = split(" ", $alpha); //spelling type here foreach ($alphaArray as $alpha) { foreach ($alphaArray as $alpha2) { echo $alpha . $alpha2 . ", "; } } ?> Spelling typo on my part. That should work. Link to comment https://forums.phpfreaks.com/topic/135845-solved-combinations/#findComment-708121 Share on other sites More sharing options...
dezkit Posted December 6, 2008 Author Share Posted December 6, 2008 Thanks, it works now Link to comment https://forums.phpfreaks.com/topic/135845-solved-combinations/#findComment-708122 Share on other sites More sharing options...
dezkit Posted December 6, 2008 Author Share Posted December 6, 2008 I got one more question, i have this right now <?php $alpha = "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"; $alphaArray = split(" ", $alpha); foreach ($alphaArray as $alpha) { foreach ($alphaArray as $alpha2) { echo $alpha . $alpha2 . "<br>"; } } ?> Is it possible so that every combination gets checked if its valid in "http://profile.mygamercard.net/*". If the gamertag exists, echo true, and if not echo false. elaborated: - php fread http://profile.mygamercard.net/x (x as in the combination of letters) - if the content displays "does not exist on Xbox Live!", echo false - Else echo true Thanks sooooooooooooooo much in advance!!! Link to comment https://forums.phpfreaks.com/topic/135845-solved-combinations/#findComment-708129 Share on other sites More sharing options...
gevans Posted December 6, 2008 Share Posted December 6, 2008 are the combinations of letters in a txt file? and are they in there line by line or seperated? Link to comment https://forums.phpfreaks.com/topic/135845-solved-combinations/#findComment-708132 Share on other sites More sharing options...
dezkit Posted December 6, 2008 Author Share Posted December 6, 2008 It's the foreach loop Link to comment https://forums.phpfreaks.com/topic/135845-solved-combinations/#findComment-708134 Share on other sites More sharing options...
gevans Posted December 7, 2008 Share Posted December 7, 2008 I meant the letters that you have set. I can see where the first array comes from Link to comment https://forums.phpfreaks.com/topic/135845-solved-combinations/#findComment-708136 Share on other sites More sharing options...
GingerRobot Posted December 7, 2008 Share Posted December 7, 2008 Is it possible so that every combination gets checked if its valid in "http://profile.mygamercard.net/*". If the gamertag exists, echo true, and if not echo false. elaborated: - php fread http://profile.mygamercard.net/x (x as in the combination of letters) - if the content displays "does not exist on Xbox Live!", echo false - Else echo true Yes, that's possible. You'd just need to parse the web page to find out if the gamertag exists or not. Of course, the website might not be too happy with you bombarding them with requests. $alpha = "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"; $alphaArray = split(" ", $alha); The range function exists for a reason Link to comment https://forums.phpfreaks.com/topic/135845-solved-combinations/#findComment-708140 Share on other sites More sharing options...
premiso Posted December 7, 2008 Share Posted December 7, 2008 Is it possible so that every combination gets checked if its valid in "http://profile.mygamercard.net/*". If the gamertag exists, echo true, and if not echo false. elaborated: - php fread http://profile.mygamercard.net/x (x as in the combination of letters) - if the content displays "does not exist on Xbox Live!", echo false - Else echo true Yes, that's possible. You'd just need to parse the web page to find out if the gamertag exists or not. Of course, the website might not be too happy with you bombarding them with requests. $alpha = "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"; $alphaArray = split(" ", $alha); The range function exists for a reason You learn something new every day =) Link to comment https://forums.phpfreaks.com/topic/135845-solved-combinations/#findComment-708143 Share on other sites More sharing options...
dezkit Posted December 7, 2008 Author Share Posted December 7, 2008 I don't care about my server, i got infinite bandwidth And yeahhhh.... uh... I don't get what does range() do Link to comment https://forums.phpfreaks.com/topic/135845-solved-combinations/#findComment-708146 Share on other sites More sharing options...
dezkit Posted December 7, 2008 Author Share Posted December 7, 2008 Anyways, does anybody know how to check if there a letter in a string? Link to comment https://forums.phpfreaks.com/topic/135845-solved-combinations/#findComment-708158 Share on other sites More sharing options...
dezkit Posted December 7, 2008 Author Share Posted December 7, 2008 Sorry for so much bumping (really i am.) but i have this code: <?php $alpha = "a b c d e f g h i j k l m n o p q r s t u v w x y z 1 2 3 4 5 6 7 8 9 0"; $alphaArray = split(" ", $alpha); //spelling type here foreach ($alphaArray as $alpha) { foreach ($alphaArray as $alpha2) { $main = $alpha.$alpha2; $filename = "http://profile.mygamercard.net/$main"; $handle = fopen($filename, "r"); if(strpos($handle, "does not exist on Xbox Live!") > 0){ echo "true"; } else { echo "false"; } } } ?> I keep getting error "Warning: fopen(http://profile.mygamercard.net/aa) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden in /home/cobi/public_html/testtt.php on line 11 false" Link to comment https://forums.phpfreaks.com/topic/135845-solved-combinations/#findComment-708162 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.