Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old February 6th, 2006, 02:36 PM
Friend of Wrox
 
Join Date: Mar 2005
Location: , , .
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to generate random non repeated numbers in php

Hi all. could an expert show me how i can generate random non repeated numbers. I want to use those number as file name that i write to. currently the file name is ram.txt but i want it the file name to be like 948450913.txt each time the scripts runs diffrent number .I be happy if an expert show me how to do that here in this code?thanks

Code:
<?php


$url[1] = "http://localhost/flash_mp3_player/mp3/08 - Track 8.mp3";
$url[2] = "http://localhost/flash_mp3_player/mp3/13 - Gar Aya.mp3";
$url[3] = "http://localhost/flash_mp3_player/mp3/Soroush - Yeh Donya - 02 Shoghe Nafas.mp3";

$mycontent = "";
if (isset($_GET["sid"]))
{
   $allsid = explode (",",$_GET["sid"]);
   $mycontent = array();
   foreach ($allsid AS $value)
      $mycontent[] = $url[$value];
}

echo $mycontent;

$handle = fopen ("ram.txt","w+");
if ($handle)
{
  if (fwrite ( $handle,implode("\r\n",$mycontent)."\r\n") )
  {
      echo "FILE IS WRITTEN SUCCESSFULLY";
  } else
  {
       echo "ERROR IN WRITING TO FILE";
  }
  fclose ($handle);
} else
{
      echo "ERROR IN OPENING FILE";
}
require 'config.txt';
?>
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to generate random numbers in xslt anboss XSLT 3 July 23rd, 2008 10:10 AM
searching a text file for repeated numbers Un33k Visual Basic 2005 Basics 1 October 30th, 2007 02:50 PM
Random Numbers Using MersenneTwister JoeDW C# 0 September 13th, 2006 12:10 PM
Random Numbers welshboy2005 C# 1 May 19th, 2005 07:01 AM
Random Numbers not so random... katsarosj ASP.NET 1.0 and 1.1 Basics 5 November 20th, 2003 12:55 AM



All times are GMT -4. The time now is 10:22 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.