|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Ziff Davis Enterprise Virtual Tradeshows: Hot Topics, Cutting Edge Technology, Real-time Interaction with IT Professionals. Learn more at ziffdavisvts.com
|
|
#1
|
|||
|
|||
|
Need help
I'm a newbie! Can someone look at this code and tell me if it looks correct? For some reason the first line is not centered but to the left of the page? For example:
Hello Goodbye
Yes No OK USA <?php $string_array = array ('Hello','Goodbye','Maybe','Yes','No','OK','USA'); $text = ""; $string_count = count($string_array); for($x=0; $x<$string_count;$x++){ $y = 0; $temp_array = array(); //reset internal pointers for $string_array foreach($string_array as $key => $value){ $key = $y; $temp_array[$key] = $value; $y ++; } $string_array = $temp_array; //generate a random number of appropriate size $random_number = rand(0,(count($string_array)-1)); //get the text from the array $string = $string_array[$random_number]; //make a temp array from that string $piece = array($string); //delte the string that was used from the array $string_array = array_diff($string_array,$piece); //add that string to the part to be printed. $text .= "$string<center>"; } echo $text; ?> |
|
#2
|
|||
|
|||
|
Ok, I found something better, I changed ($input, 2); to ($input, 5); but it still only shuffles 2? How do I fix this?
<?php srand((float) microtime() * 10000000); $input = array("Neo", "Morpheus", "Trinity", "Cypher", "Tank"); $rand_keys = array_rand($input, 2); echo $input[$rand_keys[0]] . "\n"; echo $input[$rand_keys[1]] . "\n"; ?> |
![]() |
| Viewing: SEO Chat Forums > Other > HTML Coding > Need help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|
|