Page 1 of 1

i Want to know if this is possible. I have an array say

Posted: Mon Apr 07, 2014 1:58 am
by finesofttechnologies
$colors = array( 'red', 'green' )

I want to create an array from above array as

$colors = array( 'red', 'red (2)', 'red (3)', 'red (4)','red (5)'
'green', 'green (2)', 'green (3)', 'green (4)', 'green (5)' );

Re: i Want to know if this is possible. I have an array say

Posted: Mon Apr 07, 2014 2:51 am
by requinix
If you want literally "red (2)" and such, you'll need to code that yourself using a couple loops: one over $colors and another counting from 2 to however many times you want each color repeated. Append each thing to a new array and you're done.