[ create a new paste ] login | about

Link: http://codepad.org/pwVOWeRJ    [ raw code | output | fork ]

PHP, pasted on Mar 8:
<?php

$requiredAttr = array('header', 'footer');
$boolarr = array('true', 'false');
$optAttr = array('image' );

$larr  = combine_array($requiredAttr , $boolarr , '=');

$a_arr = array_slice($larr , 0 , count($larr)/2);
$b_arr = array_slice($larr , count($larr)/2 , count($larr)/2);


$larr_1    = combine_array($a_arr , $b_arr , ' ');
$larr     = combine_array($optAttr , $boolarr , '=');
array_push($larr , ''); // for optional

$larr_3  = combine_array($larr_1 , $larr , ' ');

function combine_array($first_arr , $second_arr , $separator)
{
	$combine_arr  = array();
	for($i=0;$i<count($first_arr) ; $i++)
	{
	for($j=0;$j<count($second_arr) ; $j++)
	{
		array_push($combine_arr , $first_arr[$i].$separator.$second_arr[$j]);
	} 
	}
	return $combine_arr;
}



print_r($larr_3);



?>


Output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Array
(
    [0] => header=true footer=true image=true
    [1] => header=true footer=true image=false
    [2] => header=true footer=true 
    [3] => header=true footer=false image=true
    [4] => header=true footer=false image=false
    [5] => header=true footer=false 
    [6] => header=false footer=true image=true
    [7] => header=false footer=true image=false
    [8] => header=false footer=true 
    [9] => header=false footer=false image=true
    [10] => header=false footer=false image=false
    [11] => header=false footer=false 
)


Create a new paste based on this one


Comments: