To display or order the HTML elements with
I of the small functions or very simple PHP scripts which have some under the boot. Using two tables we will choose mark out to be displayed in our Web page and which order in order to amend the structure of our document without touching with the HTML code. With this intention, it will be enough to fill the G-string which goes well in .
in (yes, yes, I know… )
All starts with the statement of both . Could these boards be in a distinct file to include with <? “”? >:
- - contains the elements () to display,
- - makes it possible to order the elements in question.
<?
= (
“”,
“content”
);
= (
“0 ' =>' ”,
“1 ' =>' content”
);
? >
A loop and some yew.
A loop includes the whole of the document to increment the variable according to the number of elements contained in table ,
We check for each element concerned:
- its presence and its sequence number in table ,
- its presence in table .
<? (; ; ) { ? >
<? yew ( [] ==' && (“”, )) { ? > " " > of the <? }? >
<? yew ( [] ==' && (“content”, )) { ? > " content " > of the <? }? > <? } ? >
To display an element, put it in table . To amend the command of display of the elements (to place after , for example), change the command of the elements in table .
Stay tuned and mind the gap!
7 participations in the item
error: error, `=', `)' in one 8
Attention with the associative : instead of “`0 ′ =' ',” one writes “`0 ′ =>' ',”
One will put that on the back of the editor ; D
@Darklg:
, it is not the fault with … I have right pitch paid attention by transforming the opening and closing herringbones. It is repaired! Thank you for your vigilance;)
(Another register: your isn't hour of winter per? )
, the idea is interesting. How is it done in to change the command of the various elements in the side columns?
The under the condition of for it is too not, it revalues the size of the board to each loop.
Something like ( = 0, = ; <= , ) it is already better (to be checked that functions, that made an eternity which I did not do of ).
And I will find a prettier with reading, but that does not change anything; -).
Some remarks and corrections of code:
( = 0; < ; ) {
Like known as by , to put the function directly in comparison is optimized less for the referred to reason (see its correction).
Your is useless and of the blow obliges you to duplicate contents. You can abolish it and use in your .
To use an instruction “” to traverse a board is obsolete, it would be necessary to prefer to use the . The final code could thus resemble that:
= (“0” => “”, “1” => “content”,); // Sorts the board according to the keys, // the following loop will then display them in the order ; ( ace ) { (. “”); }
There would be thus an HTML page for each “”, and on behalf of this “”. Several advantages with that:
@Josselin: Thank you ' for all these precise details and these examples. Well considering, the blow of the : very subtle;)
Fortunately that all the readers are not like @Neovov: who all alone criticizes and keeps his examples for him: D (not to type, not type).