I asked a similar question earlier but I haven't been able to find anything to help me. I have now updated my code to something working but I am now completely stuck.
This is my php code:
class person {
public $name;
public $SE;
private $SD;
function __construct ( $n, $s1, $s2 ) {
$this->name = $n;
$this->SE = $s1;
$this->SD = $s2;
}
}
$Obj = new person ( "ExampleName", 5, 5 );
I need to have seperate divs created for each person, containing their names in these divs. My main problem is that after these divs are created I need to have them sorted in a particular way (that isn't any importance to you) that requires for each div to have a ID associated to the original person from which the div was created.
I am otherwise able to create divs from a list of names but not from objects. So:
I need a way to use foreach loops to create divs according to each object (person).
I need these divs associated with (linked to) that person.
Thanks for any help
Not sure what you mean by divs associated with that person but for first problem this should work.
Lets say you have an array of objects named $objs
I'm not sure this is what you're looking for, but this should work:
The objects could be sorted by name using
usort()
:Using
jQuery
you could then get an object based on the unique id:You would search in you
$persons
array to find the object with a correspondingSE
(or whatever you deside to use as the unique identifer) value: