php - How to concatenate a constant similar to concatenation of strings? -
define('household_child1','custom_16'); define('household_child2','custom_14'); define('household_child3','custom_13'); define('household_child4','custom_12'); function household_function() { $vari = array(); $var['household'][household_child1] = $_session['household_membership'][1]; $var['household'][household_child2] = $_session['household_membership'][2]; $var['household'][household_child3] = $_session['household_membership'][3]; }
i want implement above code in foreach loop similar concatenate.
it should similar this
foreach($_session['household'] $key => $value) { $var['household'][household_childi] = [i];//i need concatenate constant //to similar string }
the constant
function serve purpose:
define('household_child1','custom_16'); define('household_child2','custom_14'); define('household_child3','custom_13'); define('household_child4','custom_12'); for($i = 1; $i <= 4; $i++){ print(constant("household_child".$i).php_eol); }
the output of given code be:
custom_16
custom_14
custom_13
custom_12
Comments
Post a Comment