0

hello guys..can someone help me to create a function that generates random numbers composing of 9 digits with the ff limitations..

  • must not have consecutive numbers in any place...sample 158461247....1 and 2 is consecutive numbers...
  • must not have same numbers before and after....sample 155483628....5 and 5 is same number...

Hoping that anyone will help me regarding this matter.Thanks in advance...

4
Contributors
6
Replies
26
Views
4 Years
Discussion Span
Last Post by AARTI SHRIVAS
0

This is homework? Show us your code so far...

0
$numchars = rand(4,15); 
            $chars = explode(',','a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,0,1,2,3,4,5,6,7,8,9'); 
            $random=''; 
            for($i=0; $i<$numchars;$i++)  
                { 
                  $random.=$chars[rand(0,count($chars)-1)]; 
                } 

                $unique_id=$random;

i think this will help

0

i think this will help

I think you've tried to do the work for him :(

0

I think you've tried to do the work for him

Only showed him how to use rand. None of the OP requirements are met.

0

My bad p - didn't scan it. I was hoping the OP was going to respond before he started receiving snippets. Apologies AS. :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.