PHP program to print a random character from your name
PHP Function used are
strlen(string)
rand(min, max)
substr(string, start, length)
Method 1
<?php
$m=”Rahul”;
$len=strlen($m);
print $len;
$no=rand(0, ($len-1));
Print $no;
$char=substr($m, $no, 1);
Print $char;
?>
Method 2
<?php
$m="Rahul";
$char=
rand(0,strlen($m)-1);
// Use your
knowledge of strlen(), substr(), and rand() to
echo
substr($m,$char,1);
// print a random
character from your name to the screen.
?>
If you know some other way feel free to comment.
0 comments :
Post a Comment