array_rand() function in php

Using array_rand() function we can collect one or more elements from an array in php Otherwise, it returns an array of keys for the random entries.

{code codetype=php}
<?php
$array= array(“syam”,”ammu”,”kichu”,”david”,”John”,”abhi”);
$rand_fun=array_rand($array,2);
echo “First random element = “.$array[$rand_fun[0]];
echo “<br>Second random element = “.$array[$rand_fun[1]];

?>
{/code}

VN:F [1.9.17_1161]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.17_1161]
Rating: 0 (from 0 votes)

Related Posts

  • No Related Post
Related Posts with Thumbnails

About the Author

techremind

has written 42 stories on this site.

Write a Comment

Copyright © 2012 CoreTimer.com|System Admin’s Reference. All rights reserved.

Switch to our mobile site