I want to create a simple php function to return an array of variable in wordpress template.
php function in function.php:
function testme (){
$color = 'imaginary'; // or real
$y = 'yellow';
$s = 'silver' ;
if ($color != 'imaginary') {
$y = 'golden';
$s = 'silver' ;
} else {
$y = 'yellow';
$s = 'white' ;
}
$wall = array();
$wall = array ($y ,$s);
return $wall;
}
Called this function in my template like this:
<?php
testme();
?>
<h1>TOP STRIP COLOR IS <?php echo $wall['0'] ?></h1>
<h2>BOTTOM STRIP COLOR IS <?php echo $wall['1'] ?></h2>
But I am not getting array of values in my <h1> and <h2> tags. Help me to point out my mistake.
$s = 'silver ;<-- here$wall = testme();