Hi guys
let say i have a name called: "john"
I want to random the letters of john.
how? or what command in php to able to do this?
thank you.
| SitePoint Sponsor |
Hi guys
let say i have a name called: "john"
I want to random the letters of john.
how? or what command in php to able to do this?
thank you.
First you have to split it using str_split, then you can shuffle the array.
i know it is easy.
But i'm was rushing, it's really a BIG help from you guys when time is counting...
Thank you again...
<?php
function random_string( )
{
$character_set_array = array( );
$character_set_array[ ] = array( 'count' => 7, 'characters' => 'abcdefghijklmnopqrstuvwxyz' );
$character_set_array[ ] = array( 'count' => 1, 'characters' => '0123456789' );
$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 );
return implode( '', $temp_array );
Bookmarks