Title: to array random
Last modified: August 21, 2016

---

# to array random

 *  Resolved [Chibanga](https://wordpress.org/support/users/chibanga/)
 * (@chibanga)
 * [12 years ago](https://wordpress.org/support/topic/to-array-random/)
 * i have this code
    `<?php $my_array = get_custom_field(‘affbanner:to_array’); 
   foreach ($my_array as $item) { print $item; } ?>`
 * i have repeateble field but i want to print 1 random banner is it possible?
 * [https://wordpress.org/plugins/custom-content-type-manager/](https://wordpress.org/plugins/custom-content-type-manager/)

Viewing 1 replies (of 1 total)

 *  Plugin Contributor [fireproofsocks](https://wordpress.org/support/users/fireproofsocks/)
 * (@fireproofsocks)
 * [12 years ago](https://wordpress.org/support/topic/to-array-random/#post-4870533)
 * Yes, but that’s a php question. See the rand function [http://www.php.net/manual/en/function.rand.php](http://www.php.net/manual/en/function.rand.php)
   and the count function.
 * E.g.
 *     ```
       $size = count($my_array);
       $random_spot = rand(0, $size-1);
       print $my_array[$random_spot];
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘to array random’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/custom-content-type-manager_c9c790.
   svg)
 * [Custom Content Type Manager](https://wordpress.org/plugins/custom-content-type-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/custom-content-type-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/custom-content-type-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-content-type-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-content-type-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-content-type-manager/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [fireproofsocks](https://wordpress.org/support/users/fireproofsocks/)
 * Last activity: [12 years ago](https://wordpress.org/support/topic/to-array-random/#post-4870533)
 * Status: resolved