PHP program to print a random character from your name

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. 
Share on Google Plus

About Rahul Rana

I am an experienced web designer and SEO expert. I am running my own online marketing company i.e "SEO To Web Design". Thanks for reading, keep sharing online marketing and web design knowledge.
    Blogger Comment
    Facebook Comment

0 comments :

Post a Comment

Enter your email address:

Delivered by FeedBurner