Jump to content

Okay I am finally understanding FOREACH!!


Monkuar

Recommended Posts

$middle=array(
"aboutme" => $aboutme,
"signature" => $signature,
"friends" => $f,
);
foreach ($middle as $val =>$n)
{


$middlesection .= $middle[$val];
var_dump($middle[$val]);


}

 

Okay now How do I make this so my users can choose the ORDER of there profile sections?

 

I: have a field in my db called "profile" varchar 255!I am so excited I am actually learning Foreach with arrays this is awesome!

 

I am echoing out my $middlesection to display my 3sections: here is a screenshot:

 

 

pk5l.png

 

 

 

Now I just want my users to beable to change the order of the Array? how is this possible? :o  I am so close, eventually I want them to beable to move the sections to the left or right (I would need a 3d array though) im not that smart yet  :shrug: :shrug: :shrug: :shrug:

Link to comment
https://forums.phpfreaks.com/topic/256716-okay-i-am-finally-understanding-foreach/
Share on other sites

$middle=array(
"0" => $aboutme,
"1" => $signature,
  "2" => $f,
);
$order = array(1,2,0);
print_r($middle);
foreach ($order as $index)
{
  $middlesection.= $middle[$index];
}

 

LOL I FIGURED IT OUT!!

 

AWESOME MAN

 

LOVE IT THANKS!!!!!

 

FOREACH IS JUST FREAKING EPCI!!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.