karlo
Feb 26 2005, 10:12 AM
| | First of all, if you have answers to the following
QUOTE 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! |
Reply
mobious
Feb 28 2005, 12:21 PM
QUOTE(karlo @ Feb 26 2005, 06:12 PM) 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! 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.
Reply
karlo
Mar 2 2005, 06:44 AM
QUOTE(mobious @ Feb 28 2005, 08:21 PM) 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. 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.
Reply
mobious
Mar 2 2005, 10:07 AM
QUOTE(karlo @ Mar 2 2005, 02:44 PM) 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. for an array: CODE $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++CODE 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. CODE function get_microtime() { list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); }
Reply
karlo
Mar 2 2005, 02:23 PM
CODE function get_microtime() { list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); } so what's the list() function? and return() function?
Reply
mobious
Mar 3 2005, 02:21 PM
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: CODE 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"
Reply
Similar Topics
Keywords : php functions- Functions
- ??? (6)
- Wappy's Php Snippets
- I will place here usefull php snippets and functions that i learn/use (13)
Here is a function you can use to generate a simple random password for whatever use ;-) CODE
<? function rand_pass($numchar){ $string = str_shuffle
("abcdefghijklmnopqrstuvwxyz1234567890"); $password = substr ($string,
1, $numchar); return ($password); } //example echo
rand_pass('8'); // will return an 8 character long random password of numbers and
letters like c8k4ss42 ?> CODE tags added. Here is an extremly usefull search function
that will search a directory and...
Php Email Validation
- A PHP data validation class with many functions (1)
I've been reading through my old php book (PHP 4.1) and came across this data validation class.
It can check a number of things ranging from telephone numbers , credit card number formats, email
address and some others. I checked out some of the methods although I didnt expect it to work 100%
because I've found source code errors thoughout the book and CD. I tested out a few of the
methods to check and some of them did return expected results but some didnt either so the data
validation class was not perfect and it didnt really bother me. The cool thing I found...
Php Functions To Send Mail
- (4)
Which other methods to send mail from a form? I just know mail function, like: mail(string to,
string subject, string message) Has anyother?...
Arrays Outside A Function
- Need to have arrays available to all functions. (3)
I've got a bunch of arrays that i want to use for more then 1 function. when i declear the
arrays outside a function i cant use it in a function. This code was originally written in
javascript by another person but since I plan to use it and extend it with php I had to change it
from javascript to php code. In the javascript code the arrays were decleared outside the functions
with 'var arrayname' I read somewhere that declearing javascript variables with
'var' gives it global access. Any ideas on how I can go about declearing 1 set of these
arrays t...
Encrypt Functions
- (0)
Here is my 3rd Code: By this code you can encrypt your text: CODE <?php $a =
md5("hello"); $b = base64_encode("hello"); $c =
base64_decode("hello"); print "md5 = ".$a." base64_encode =
".$b." base64_decode = ".$c; ?> EASY!...
[php](simple) Using Functions To Combine Values In A Form
- Really simple example on how to combine values with function (2)
I just learned this simple method on how to use functions to combine two values from a form. First
we create ourselves a simple POST form CODE <form method="POST"> Name:
<input type="text" name="nickname"> Location: <input
type="text" name="location"> <input type="submit"
value="Input"> </form> Now we add this php to that same file CODE
<?php $nick = $_POST['nickname']; $location =
$_POST['location' ...
Gd Functions
- Questions (2)
Hi all I want begin a new project , my new project is Photo blog ( weblog and image album ) in one
script for example you can post many image in one post at once case . so its very good and very easy
but we have some problems . if you can plz help me to fix this problems for example : we need
change image size for page speed ( we dont want show 16 image in one page ) * we need GD functions
to change image size to smaller and then show smaller image at page if you know source or tutorial
about change image size plz post here . thankx we know we can change image size (w...
Some Php Functions Explaination Required
- (2)
Can some one please tell me what is the purpose of the following functions , although there's a
little explaination with everyline but i cant understand, can some one exaplin it bit clearly and
tell me that why it is needed in config.inc.php.. what is its purpose and will it work if i dont
include these files in config.inc.php thanks QUOTE ### Url were Website has been installed, not
'/' in end! define('C_URL','http://www.test.com/Website'); ### Internal
path to Website directory define('C_PATH','Z:/home/www.test.com/www/...
Globals Inside Functions
- (4)
I've got the following function, that has a function inside of it, when I run it I get the
followin error: PHP Code: CODE Fatal error: Call to a member function on a non-object in
See the code below where I get the error message. I'm guessing the scope of my varaibles is
messed up, but I'm not sure how to fix it. I've abbreviated the code so as to make it easier
to read. PHP Code: CODE function getMemberRegistrationForm( &$tpl, &$db ) {
function displayRegistrationForm( $action, &$db, $defaults =...
Using The Image Editing Functions Of Php
- Specifically, lines or regular polygons. (4)
I've been experimenting a little with PHP's image functions and I was trying to see if I
could make something that looked 3D, so I started with a cube because it's simple. To make an
isometric picture of a cube, you need to start with a regular hexagon. However, making a regular
hexagon isn't the easiest thing. Is there a function to create a regular polygon, or specify an
angle and magnitude for a vector?...
Writing Your Own Functions In Php
- how do i write php functions that takes arguments in php? (2)
I'll set up the background for the question: I have a separate file that I include on all the
webpages on my site which I call with PHP using the include() function, so everything will be much
easier to maintain and update. Well, I have three include files for each page: header.php (includes
stuff like meta tags, googlebot/spider info), footer.php (the footer/copyright thing), leftnav.php
(includes the navigation bar). I also like the titles of my pages to be as descriptive as possible
so I try to include the path of a page (how the user got to that page: "Excite Y...
Looking for confused, php, functions, confused
|
|
Searching Video's for confused, php, functions, confused
|
advertisement
|
|