<?php
// Sunyanzi @
V2EX/* make a flowerpot ... */
$flowerpot = [];
/* we have 7 seeds at first ... */
seeding_time( $flowerpot, 0, 7 );
/* simple output ... */
echo( implode( ' ', $flowerpot ) );
/* main function ... using Recursion which is @
alexrezit's favourite ... */
function seeding_time( &$ret, $prefix, $number ) {
/* the seeds we planted can sprouted ... */
static $seeds = [
3 => 5,
7 => 2,
31 => 3
];
/* seeding in progress ... */
for ( $i = 1; $i <= $number; ++ $i ) {
/* most easy way to get seed number ... */
$s = intval( $prefix . $i );
/* push into result ... */
$ret[] = $s;
/* we have magic on this seed ..? */
if ( isset( $seeds[$s] ) )
seeding_time( $ret, $s, $seeds[$s] );
}
/* we have done ... */
return;
}
// --------------------------------------------------
// DEMO OUTPUT
// --------------------------------------------------
// 1 2 3 31 311 312 313 32 33 34 35 4 5 6 7 71 72
// --------------------------------------------------