tags:

views:

22

answers:

1

Is there a fairly easy way to sort div id's with php? I tried a jquery script to sort it be it gave a big delay on the page load.

Example html part (unsorted)

<div id="1">Content1</div>
<div id="3">Content3</div>
<div id="2">Content2</div>

Example html part (End result, Sorted with php or java)

<div id="1">Content1</div>
<div id="2">Content2</div>
<div id="3">Content3</div>

Thank you, Bjorn

+1  A: 

You can, using the DOM extension. See DOMNode::insertBefore and DOMNode::removeChild.

However, you should ask yourself why they're unsorted in the first place.

Do they come from a database? In that case you can sort the query. They come from some place else? Try to to reorder the data before building the HTML markup.

Artefacto
Those are good questions and a great way of approaching programming problems in the first place
Wayne Werner
The result comes back as text from a php file. Let's say I run result.php?id=content321 and it will give me back the reply "0" or "1"These replys are set into the div or anywhere else I wanna have them.
Bulfen