/    Sign up×
Community /Pin to ProfileBookmark

Run a single Multi-Dim Array instead of Multi-Single arrays

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(
‘/&#37;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();
?>
[/code]

Here’s a section.

[code=php]
extract( $b = section( ‘U Series’, ‘snd’, ‘us/’ ) );
$noko = array( $r++ => ‘4’, $r++ => ‘u8’, $r++ => ‘&#946;&#8323; U8’); xR();
$noko = array( $r++ => ‘1’, $r++ => ‘u6’, $r++ => ‘&#946;&#8323; U6’); xR();
/* removed for brevity */
$noko = array( $r++ => ‘1’, $r++ => ‘u12b’, $r++ => ‘&#946;&#8323; U12B’); xR();
$noko = array( $r++ => ‘1’, $r++ => ‘u15b’, $r++ => ‘&#946;&#8323; U15B’); xR();
[/code]

Here’s how I consolidated into a multi-dim

[code=php]
$minefield = array(
array( $r++ => ‘4’, $r++ => ‘u8’, $r++ => ‘&#946;&#8323; U8’),
array( $r++ => ‘5’, $r++ => ‘u8a’, $r++ => ‘&#946;&#8323; U8a’),
/* removed for brevity */
array( $r++ => ‘1’, $r++ => ‘u12b’, $r++ => ‘&#946;&#8323; U12B’),
array( $r++ => ‘1’, $r++ => ‘u15b’, $r++ => ‘&#946;&#8323; U15B’),
);
extract( $b = ion( ‘U Series’, ‘snd’, ‘us/’, $minefield ) );
[/code]

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….

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@ehimeauthorFeb 04.2010 — Just a little reasoning behind [b]why[/b] I'm doing this

I'm currently working on a function that will traverse these

files that I store array data in, and pull the contents for a

$_GET later on. This will make my products "Bookmark-able"

later on, seeing how I use $_
POST to push products.

Should Be Good ?
×

Success!

Help @ehime spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...