PHP function loop through variables and output it -


i'm trying make little php function can create , change links in website. using jquery plugin hash pages, website driven on, hash based website, use lot , @ point if want change url setup take forever go through each place , it.

i've got right now, work first 2 variables, problem there 1 variable returned sometimes, , other times there 2, or 4, , in future more 4 have defined.

function href($page, $pageid, $subpage, $subpageid) {  $href = 'href="#/'.$page.'/'.$id.'" rel="address:/'.$page.'/'.$id.'"';  return $href;    } 

the finished links these:

<a href="#/home" rel="address:/home"></a> 

and or

<a href="#/profile/1" rel="address:/profile/1"></a> 

and or

<a href="#/profile/1/subpage/2" rel="address:/profile/1/subpage/2"></a> 

etc.

and accomplish using function, , usage along lines of:

<a <?php echo href('home')?>></a> 

and or

<a <?php echo href('profile', '1')?>></a> 

and or

<a <?php echo href('profile', '1', 'subpage')?>></a> 

etc.

any how solve appreciated, thanks!

try this:

function href(){     $url = implode('/', func_get_args());     $href = 'href="#/'.$url.'" rel="address:/'.$url.'"';     return $href;    } 

when calling href('hello', 'world', '1');, should return string

href="#/hello/world/1" rel="address:/hello/world/1" 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -