הרשם שאלות ותשובות רשימת חברים לוח שנה הודעות מהיום

חזור   הוסטס - פורום אחסון האתרים הגדול בישראל > עיצוב גראפי, תכנות על כל שפותיו וקידום ושיווק אתרים > פורום תיכנות

   
|!|

השב
 
כלים לאשכול תצורת הצגה
ישן 22-01-07, 20:55   # 1
בניה
משתמש - היכל התהילה
 
מיני פרופיל
תאריך הצטרפות: Oct 2005
מיקום: נחושה
הודעות: 3,434

בניה לא מחובר  

PHP קוד:
<?php
error_reporting
(E_ALL);
class 
generator
{

    
/**
    * Chars array
    *
    * The list of the Chars of the strings
    *
    * @access private
    * @var Char array
    */
    
var $tags;

    
/**
    * Tags num
    *
    * The num of the Tags in the tags array
    *
    * @access private
    * @var int
    */
    
var $tags_num;

    
/**
    * code array
    *
    * The current array that contain the chars of the generator output
    *
    * @access private
    * @var string
    */
    
var $code;




function 
generator$start_length )
{
    for(
$i=1$i<=$start_length$i++)
        
$this->code[]=0;
    
$this->tags=array
    (
        
"1","2","3","4","5","6","7","8","9","0",
        
"a","b","c","d","e","f","g","h","i","g","k","l","m"
        
,"n","o","p","q","r","s","t","u","v","w","x","y","z"
    
);
    
$this->tags_num=count($this->tags);
    
$this->update_key=0;
}
function 
next_code()
{
    if(
$this->code[$this->update_key]>=$this->tags_num-1)
    {
        for(
$i=0$i<=$this->update_key$i++ )
            
$this->code[$i]=0;
        
$this->update_key++;
        
$this->code[]=-1;
        
$this->next_code();
        
$this->update_key=0;
    }
    else
    {
        
$this->code[$this->update_key]++;
    }
}
function 
get_code()
{
    
$thecode "";
            foreach(
$this->code as $key=>$value)
            {
                
$thecode.= ($this->tags[$value]);
            }
    
$this->next_code();
    return 
strrev($thecode);
}

}

$codes = new generator();
for(
$l=1$l<=10$l++)
    {
        echo 
$codes->get_code()."<br />";
    }
?>
אם אתה רוצה שהקוד יתחיל ממחרוזת בגודל יותר גדול מ1 אז תעביר את הגודל הרצוי כפרמטר לפונקציה generator ככה:

PHP קוד:
$codes = new generator(4); 
  Reply With Quote
השב

חברים פעילים הצופים באשכול זה: 1 (0 חברים ו- 1 אורחים)
 


חוקי פירסום
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 מופעל
סמיילים הם מופעל
[IMG] קוד מופעל
קוד HTML מכובה

קפיצה לפורום


כל הזמנים הם GMT +2. הזמן כעת הוא 12:48.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ