I have this function:
function my_function($value1, $value2, $value3 = null){
if($value1 || $value2 || $value3 == 'my_title' ){
echo '<title>'.$value2.'</title>';
}
}
my_function('my_css', 'my_title');
So as you can see I had to put in the echo $value2 becuase I cannot figure out how I would be able to use either $value 1,2 or 3. I was thinking this could be solved by doing something like this:
if($value1 || $value2 || $value3 == 'my_title' $title = $value1 || $value2 || $value3 ){
Is this possible?
I hope you can understand what im trying to achieve here.
---------------------------------------------------- SOLVED --------------------------------------------------------
Thanks to rohitarora for the best answer for this question.
i would like to share with everyone what you have helped me make.
if you have this function
function template_content($value1, $value2, $value3 = null){ global $title;
$value = array($value1, $value2, $value3);
for($i=0;$i<count($value);$i++)
{
if (strpos($value[$i],'title: ') === 0 ){
$title = explode("title: ",$value[$i]);
echo "\t", '<title>'.$title[1].'</title>', "
";
} else if (strpos($value[$i],'css: ') === 0 ){
$css = explode("css: ",$value[$i]);
echo "\t", '<link rel="stylesheet" href="'.$css[1].'">', "
";
} else if (strpos($value[$i],'js: ') === 0 ){
$js = explode("js: ",$value[$i]);
echo "\t", '<script src="'.$js[1].'"></script>', "
";
}
}
}
you can call this function
<!DOCTYPE html>
<html>
<head>
<?php template_content('css: http://google.com/style.css', 'title: hello', 'js: http://code.jquery.com/jquery-latest.min.js'); ?>
</head>
<body>
</body>
</html>
and you will get this amazing result
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="http://google.com/style.css">
<title>hello</title>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
</body>
</html>