Re: [PHP] mt_strand

2004-02-13 Thread Richard Davey
Hello Angela,

Friday, February 13, 2004, 10:37:47 AM, you wrote:

AKH> However - I'm not 100% sure how to incorporate it into my code - I have
AKH> tried a few things but each time I break the code.

Your make_seed() function isn't going to work in this instance because
the important parts of it are outside of the function scope.



If you look carefully you'll see that all the function itself does is
return a unique value - the two commands that follow the function
(mt_srand and $randval=) use that result, but they're not part of the
function. So in essence just calling the function will never actually
work.

To get this to work in your code you would need to place the function
and mt_srand line somewhere at the start of your script.

Personally, it I think it'd be easier to do this which is a similar
approach but with a small re-write:



The above is un-tested but should work fine, just reply to this email
if it gives you a syntax error and I'll track it down.

-- 
Best regards,
 Richardmailto:[EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] mt_strand

2004-02-13 Thread Jason Wong
On Friday 13 February 2004 18:37, Angela K Hilton wrote:

> I could do with some pointers in using mt_strand.>

You do mean mt_srand() ?

[snip]

> mt_srand(make_seed());

Just do the above *once*, somewhere near the top of your code (anywhere before 
you use mt_rand()).

Then just use mt_rand() wherever you need it, like eg:

  $image = $random[mt_rand(0, count($random)-1)];

If you're just picking a random item from an array. the nice people who 
develop php have provided a function to do just that, array_rand(). RTFM 
before use.

> However - I'm not 100% sure how to incorporate it into my code - I have
> tried a few things but each time I break the code.

It would help if you stated exactly what you did and how your code was broken.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
I've run DOOM more in the last few days than I have the last few
months.  I just love debugging ;-)
(Linus Torvalds)
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] mt_strand

2004-02-13 Thread Angela K Hilton
Hamid



works fine - all the code works OK - apart from the seed issue.

A

***
Angela K Hilton
Web & E-Learning Officer
ISD, UMIST
Tel: 0161 306 3109
***


-Original Message-
From: Hamid Hossain [mailto:[EMAIL PROTECTED] 
Sent: 13 February 2004 10:45
To: [EMAIL PROTECTED]
Subject: RE: [PHP] mt_strand

Hi Angela,

I don't understand why you are using the following line:


You have to use somthing like:


The other part of your code looks fine to me.

Regards,
Hamid

---
Check Amazon.com's Latest PHP books:
http://www.amazon.com/exec/obidos/redirect?tag=zawraqclassif-20&path=tg/
browse/-/295223

Start Accepting CreditCard at your site in minutes:
http://www.2checkout.com/cgi-bin/aff.2c?affid=106720

Download Alexa Tool Bar to stop Pop-ups for FREE:
http://download.alexa.com/?amzn_id=zawraqclassif-20

Download Ready-Made Templates for your site:
http://www.aplustemplates.com/cgi/affiliates/c1.cgi/zawraq_ad
---

Original Message Follows
From: "Angela K Hilton" <[EMAIL PROTECTED]>
To: "PHP-General" <[EMAIL PROTECTED]>
Subject: [PHP] mt_strand
Date: Fri, 13 Feb 2004 10:37:47 -

Hi All

I could do with some pointers in using mt_strand.

I understand that because my server has 


  and have found the following in the PHP manual:



However - I'm not 100% sure how to incorporate it into my code - I have
tried a few things but each time I break the code.

Any help will be appreciated.

Thanks
Ange
***
Angela K Hilton
Web & E-Learning Officer
ISD, UMIST
Tel: 0161 306 3109
***

_
Protect your PC - get McAfee.com VirusScan Online 
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php