Top Questions

  • 2.9 Years

    • Category : Php
    • Location : Chandigarh
    • Posted On : Mar 30, 2016

    You can generate refer code or random code using this code in php.its easy to implement and use.

    <?php
        $character_set_array = array();
        $character_set_array[] = array('count' => 6, 'characters' => 'abcdefghijklmnopqrstuvwxyz');
        $character_set_array[] = array('count' => 1, 'characters' => '0123456789');
        $character_set_array[] = array('count' => 1, 'characters' => '!@#$ -*&?:');
        $temp_array = array();
        foreach ($character_set_array as $character_set) {
            for ($i = 0; $i < $character_set['count']; $i   ) {
                $temp_array[] = $character_set['characters'][rand(0, strlen($character_set['characters']) - 1)];
            }
        }
        shuffle($temp_array);
        $refercode= implode('', $temp_array);
        echo $refercode;
        ?>

Add Your Answer

When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.