devWhiz Posted June 2, 2011 Share Posted June 2, 2011 I need to be able to echo everythink that is in an array, It has to echo all of them, the code I have written would only echo 3 out of the 5 sometimes less sometimes it will repeat the same thing 2 or 3 times, I need it to be different each time, it should be able to echo all 5 parts of the array randomly and then it keep going in a cycle... ive tried array_rand() rand() shuffle() with no luck, Any help is appreciated, Link to comment https://forums.phpfreaks.com/topic/238172-need-some-help-with-this/ Share on other sites More sharing options...
mikesta707 Posted June 2, 2011 Share Posted June 2, 2011 um, use a foreach loop? $array = array(some stuff in here) foreach ($array as $value) { echo $value . "<br />"; } or you could just use print_r print_r($array); Link to comment https://forums.phpfreaks.com/topic/238172-need-some-help-with-this/#findComment-1223915 Share on other sites More sharing options...
Pikachu2000 Posted June 2, 2011 Share Posted June 2, 2011 Not sure I follow completely, but I think you mean something like this? $array = range( 1, 5 ); for( $i = 0; $i < 5; $i++ ) { shuffle($array); echo implode(', ', $array) . '<br>'; } Link to comment https://forums.phpfreaks.com/topic/238172-need-some-help-with-this/#findComment-1223919 Share on other sites More sharing options...
devWhiz Posted June 2, 2011 Author Share Posted June 2, 2011 let me see if I can explain with more detail basically what I can trying to do is this I have a file with ID numbers and security keys for my user accounts in this format // ID(space)Security Key 12354390 48ghsgyew89380sdjoakk 12345560 38gdsfdsgdfhfdsfdsfwwrk 12346660 48jod43dsgdrfgdfewewrk That is just gibberish above to show as an example, this is the code I use to sort the ID and security tokens from the text file <?php $keys = file($info_file); foreach($keys as $values) { $Var = explode(' ', $values); $Info[] = array($Var[0], trim($Var[1])); } ?> so after using that ... $Info[0] would equal 12354390 and $Info[1] would equal 48ghsgyew89380sdjoakk Here is the loop I use $Variable[] = "var 1"; $Variable[] = "var 2"; $Variable[] = "var 3"; for($i=0; $i<count($Info); $i++) { for($a=0; $a<count($Variable); $a++) { $load = file_get_contents('http://www.example.com/k?='.$Info[$i][0].'&variable='.$Variable[$a].'&security='.$Info[$i][1]); sleep(1); } } I need to randomize the $Info array in the file_get_contents and I would like to randomize the $Variable as well, the "$i" in $Info[$i][0] amd $Info[$i][1] has to be the same so it matches up, or else it would failed the security check... I would need it to randomize but not repeat any of the variables when it loads the webpage, cannot repeat, or cannot miss any, I know that sounds confusing Lol, let me know and I will try to explian a little bit better Link to comment https://forums.phpfreaks.com/topic/238172-need-some-help-with-this/#findComment-1223926 Share on other sites More sharing options...
devWhiz Posted June 2, 2011 Author Share Posted June 2, 2011 anyone? Link to comment https://forums.phpfreaks.com/topic/238172-need-some-help-with-this/#findComment-1224354 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.