UPDATE
Sorry. I wasn’t as clear as I need to be I think. I am basically trying to insert more than a text string. The function is in wordpress and pulls in html code from the dashboard for ads.
<ul id="randomOrderList">
<li><?php if (function_exists('dfrads')) { echo dfrads('1'); } ?></li>
<li><?php if (function_exists('dfrads')) { echo dfrads('2'); } ?></li>
<li><?php if (function_exists('dfrads')) { echo dfrads('3'); } ?></li>
</ul>
To this:
<ul id="randomOrderList">
<li><a href="" title=""><img src="name" alt=" " /></a></li>
<li><a href="" title=""><img src="name" alt=" " /></a></li>
<li><a href="" title=""><img src="name" alt=" " /></a></li>
</ul>
I tried this but I am not sure how to add the php in the array:
<?
$array=array('<?php if (function_exists('dfrads')) { echo dfrads('1'); } ?>','<?php if (function_exists('dfrads')) { echo dfrads('2'); } ?>','<?php if (function_exists('dfrads')) { echo dfrads('3'); } ?>');
shuffle($array);
$array = array_chunk($array, 5);
foreach($array as $section){
echo '<ul id="randomOrderList">'."\n";
foreach($section as $link){
echo ' <li>'.$link.'</li>'."\n";
}
echo '</ul>'."\n";
}
?>
You could put your strings into an array :
Without any kind of code — which is not permitted in there.
Then, use the
shuffle()function to randomize the array :And, now, loop over your array, to display the items :
They will be displayed in random order.
Edit after edit of the question : you can construct the array calling your function, of course.
For example, you can use something like this :
If needed, you can include all your code inside a test for the existence of the
dfradsfunction :