This code gets a letter ($letter) from the array ($alphabet) randomly. This PHP is at the top of the functions.php file in WordPress and gets used in an action to echo the $letter in an email when an order is placed in woo.
How do I change the code so $letter holds the next letter each time the action is is called? So the 1st email echos ‘a’ , 2nd email ‘b’ e.t.c.
$alphabet = array ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' ); $rand_keys = array_rand($alphabet, 1); $letter = $alphabet[$rand_keys] . "\n";
Thank you in advance.
- The topic ‘Sequential selection from array’ is closed to new replies.