karlo 0 Report post Posted February 26, 2005 (edited) First of all, if you have answers to the following http://forums.xisto.com/topic/7653-a-lot-of-php-questions-please-do-help-me/ http://forums.xisto.com/topic/7651-a-lot-of-html-questions-need-help-here-html-experts/ Feel free to answer them all. Now, in PHP i know there's microtime, srand, float, array_rand, arrays, foreach, or any other loop functions. i'm really confused. Please help me! Edited February 26, 2005 by karlo (see edit history) Share this post Link to post Share on other sites
mobious 0 Report post Posted February 28, 2005 First of all, if you have answers to the following Feel free to answer them all. Now, in PHP i know there's microtime, srand, float, array_rand, arrays, foreach, or any other loop functions. i'm really confused. Please help me! 54284[/snapback] microtime() is a funtion that will return the time in seceonds as well with the microseconds. srand() is a function that seeds a random value generator. if you are confused of what a seed and a number generator is.. then just stick to the rand() function. a float is a data type. it is an integer with a decimal point like 1.5, 0.5 and 0.1. array_rand() is a funtion that picks one or more keys. the value returned will be an array with the keys that were randomly picked. An array in PHP is actually an ordered map. A map is a type that maps values to keys. This type is optimized in several ways, so you can use it as a real array, or a list (vector), hashtable (which is an implementation of a map), dictionary, collection, stack, queue and probably more. it's really hard to explain because there are many types of arrays. foreach loop is used with an array. the arguments are used here as a reference to the keys and the values of the array. the loop start from where the pointer is. so if the pointer is at the end of the array, the loop will not work. you have to reset the array. Share this post Link to post Share on other sites
karlo 0 Report post Posted March 2, 2005 microtime() is a funtion that will return the time in seceonds as well with the microseconds. srand() is a function that seeds a random value generator. if you are confused of what a seed and a number generator is.. then just stick to the rand() function. a float is a data type. it is an integer with a decimal point like 1.5, 0.5 and 0.1. array_rand() is a funtion that picks one or more keys. the value returned will be an array with the keys that were randomly picked. An array in PHP is actually an ordered map. A map is a type that maps values to keys. This type is optimized in several ways, so you can use it as a real array, or a list (vector), hashtable (which is an implementation of a map), dictionary, collection, stack, queue and probably more. it's really hard to explain because there are many types of arrays. foreach loop is used with an array. the arguments are used here as a reference to the keys and the values of the array. the loop start from where the pointer is. so if the pointer is at the end of the array, the loop will not work. you have to reset the array. 54799[/snapback] Can you give me an example of those array, loops, and randomizing functions? and microtime functions? and also please include a tutorial for those kind of things. Share this post Link to post Share on other sites
mobious 0 Report post Posted March 2, 2005 Can you give me an example of those array, loops, and randomizing functions? and microtime functions? and also please include a tutorial for those kind of things. 55403[/snapback] for an array: $array = array("Key1" => "Value1, "Key2" => "Value2"); there are many types of loops. this is one of them. The for loop. this loops works in a simple way. it sets an initial value for a variable then check it with the condition then if it is true, executes the commands inside the loop and executes a command to change the value of the variable and the loop is ready for another processing. In this example the variable is $x and the condition is $x < 10 and the code we used to change the value of $x is $x++ for ($x = 1; $x < 10; $x++) { print $x;} PHP already has a function for generating a random number. the function is rand(). Here is a simple function to get the current microseconds. this function is also used to time your script's execution time. function get_microtime() { list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); } Share this post Link to post Share on other sites
karlo 0 Report post Posted March 2, 2005 function get_microtime() { list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); } so what's the list() function? and return() function? Share this post Link to post Share on other sites
mobious 0 Report post Posted March 3, 2005 list assigns variables as if they were an array. in the get_microtime() function an array was returned from the function explode(). list() then was used to assign variables for the elements of the array.return() is used to return a certain value from function to a variable. example: function test () { $test = "test"; return($test);}//when the function is referenced by a variable, the value returned will be//the new value of the variable.$string = test();//$string now has a value of "test" Share this post Link to post Share on other sites