Newbie here
I am working on a small project which I use the following code show below on about 12 pages, and in time will likely use it in another twelve. To me, that seems like I ought to make it into a function and i've looked over at PHP.NET and read some cool stuff, and did some googles but nothing quite answered my question in a way I understood. I understand how to make a generic function (i.e. function EchoSomething(){echo 'print something';}. But I don't understand how to construct a function that would call an array and run it in a for each loop.
This is my starting code that, aside from using a different array name every time, is otherwise identical:
<?php
foreach($aaGenR1 AS $key => $value){
echo '<div class="3u"><a href="_img/fulls/' . $key .'" class="image full"><img src="_img/thumbs/' . $key .'" alt="" title="' . $value .'" /></a></div>';
}
?>
It seems to me that i ought to be able to write something like
function GetPortfolioArray(){
echo '<div class="3u"><a href="_img/fulls/' . $key .'" class="image full"><img src="_img/thumbs/' . $key .'" alt="" title="' . $value .'" /></a></div>';
}
And then when i would call the function in my code, i'd write 'GetPortfolioArray($arrayNameToBeUsed)'
I think i'm close, I hope i'm close anyway. Help is appreciated. thank you.
Cheers