I have sections that look like this right now, you can see that I’m
running the function xR(); after each array. I would like to instead
push all these into a single multidimensional array and run a single
function (most likely section() abbr ion()) at the end of the multi
dim to take care of the arrays before.
Here’s the function that I was trying to get (unsuccessfully) to
work, I can post the origional working section if anyone wants
though!
[code=php]
<?
function ion( $area = NULL, $sct, # Never set as NULL
$img = NULL, $path,# Never set as NULL
$minefield = NULL) {
GLOBAL $r; $r = 0; # restart $r
if(isset( $area )) { echo “<div class=”section”> $area </div>”;
} else {
# Is header function
include ($_SERVER[‘DOCUMENT_ROOT’] . ‘/include/head.php’);
echo ‘<div><img alt=” class=”head” src=”‘ . $hds
. $img . ‘.jpg” /></div><div class=”bigBox”>’.”n”; }
return array ( ‘area’ => $area, ‘sct’ => $sct,
‘img’ => $img ‘path’ => $path );
if(isset( $minefield )) {
GLOBAL $noko; # Anymore?
# This needs to foreach for the minefields arrays
$query_string = http_build_query( $noko );
$query_string = preg_replace(
‘/%5B( ?:[0-9]|[1-9][0-9]+ )%5D=/’,
‘=’, $query_string );
$encode = base64_encode( $query_string );
$find = array( ‘”‘, ”’, );
$replace = array( ‘”‘, ”;’ );
$path = str_replace(‘|’, ‘/’, $path);
$token = uniqid();
$dir = curPageName(preg_replace( ‘/.[^.]*$/’, ”, $dir ));
$noimg = ‘http://omnisistem.com/images/noimg’;
$home = ‘http://omnisistem.com/’;
$src = $home . ‘images/products/’ . $sct . ‘/’ . $path;
$img = ( $noko[0] == 0 ) ? $noimg : $src.$noko[1].’-01′;
$s = ( $noko[0] > 0 ) ? TRUE : FALSE;
echo “n”.'<div class=”k”><form action=”.$home.’php/page.php?’
.$dir.chr(43).$noko[1].”id=”ID_’.$token.'” method=”post”>’;
echo “n”.'<p><input type=”image” class=”pImg” ‘.’id=”imgBig_’
.$token.'” src=”‘.$img.’-m.jpg” /></p>’.”nn”;
if( $s ) {
$r = 0;
# Start ICO Cycle
echo ‘<div class=”ico”>’.”n”;
$k = $noko[0]; # Normalize IMG Count
$a = $b = ( $k > 6 ? 6 : $noko[0] );
$a = ( $a == 1 ? 0 : $a );
$c = 0; $i = 1; while ( $i <= $a ):
$t = str_pad( $i, 2, “0”, STR_PAD_LEFT );
echo ‘<a rel=”shadowbox[‘.$noko[1].’];” title=”‘.$noko[2]
.'” class=”h” href=”‘.$src.$noko[1].’-‘.$t.’.jpg”>’
.'<img alt=” onmouseover=”roll( ”.$src.$noko[1].’-‘.$t
.’-m.jpg’,”.$src.$noko[1].’-‘.$t.’-m.jpg’,”
.$token.”,”.$c.” );”‘.’src=”‘.$src.$noko[1].’-‘.$t
.’-ico.jpg” /></a>’.”n”; $i++; $c++;
endwhile;
echo “</div>”; # Close ICO Cycle
}
echo “n”.'<div class=’f’><input class=”nxt” value=”‘
.$noko[2].'” type=’submit’/>’.”nn”.'<p>’
.'<input type=’hidden’ value=”‘
.$noko[0].'” id=”icoLength’.$token.'” /></p>’;
$path = str_replace(‘/’, ‘|’, $path); # Protect Directories
echo( “<p><input type=”hidden” value=”$sct” name=”sct” /></p>”.”n” );
echo( “<p><input type=”hidden” value=”$encode” name=”encode” /></p>”.”n” );
echo( “<p><input type=”hidden” value=”$path” name=”path” /></p>”.”n” );
echo ‘</div></form></div>’;
$r = 0; # reset $r
} // xR();
?>
Here’s a section.
[code=php]
extract( $b = section( ‘U Series’, ‘snd’, ‘us/’ ) );
$noko = array( $r++ => ‘4’, $r++ => ‘u8’, $r++ => ‘β₃ U8’); xR();
$noko = array( $r++ => ‘1’, $r++ => ‘u6’, $r++ => ‘β₃ U6’); xR();
/* removed for brevity */
$noko = array( $r++ => ‘1’, $r++ => ‘u12b’, $r++ => ‘β₃ U12B’); xR();
$noko = array( $r++ => ‘1’, $r++ => ‘u15b’, $r++ => ‘β₃ U15B’); xR();
Here’s how I consolidated into a multi-dim
[code=php]
$minefield = array(
array( $r++ => ‘4’, $r++ => ‘u8’, $r++ => ‘β₃ U8’),
array( $r++ => ‘5’, $r++ => ‘u8a’, $r++ => ‘β₃ U8a’),
/* removed for brevity */
array( $r++ => ‘1’, $r++ => ‘u12b’, $r++ => ‘β₃ U12B’),
array( $r++ => ‘1’, $r++ => ‘u15b’, $r++ => ‘β₃ U15B’),
);
extract( $b = ion( ‘U Series’, ‘snd’, ‘us/’, $minefield ) );
On of the things that needs to be kept in mind is that after each “Pass” I reset $r = 0;
so each array starts at zero. It makes duplicating fields easy….