Aloha chaps,
I've been abusing some code recently and developed the following:
I've naughtily used 3 arrays where no doubt a multi di array would have done, but my issue was at the bottom when adding them to the branch I was unsure on how to access the necessary data.
The 3 arrays contain info for a course, and they are all in order. When using my multi array I could get the content first, but the next item which should have been content was an action.. etc
If someone could show me how to tidy this up that would be great. Oh and I am pulling content out of an array $mycourses, to put into another array to reverse because $mycourses is the biggest multi di array you've ever seen and I can't use reverse_array on it.
I've been abusing some code recently and developed the following:
PHP:
//get course contents actions and titles in 3 simple arrays
$coursecontents = array();
$courseactions = array();
$coursetitles = array();
foreach ($mycourses->children as $coursenode) {
$coursecontents[] = $coursenode->get_content();
}
foreach ($mycourses->children as $coursenode) {
$courseactions[] = $coursenode->action;
}
foreach ($mycourses->children as $coursenode) {
$coursetitles[] = $coursenode->get_title();
}
//reverse courses as they come out in the wrong order
$reversedcontent = array_reverse($coursecontents);
$reversedactions = array_reverse($courseactions);
$reversedtitles = array_reverse($coursetitles);
//print_r($reversedcontent);
//print_r($reversedactions);
//print_r($reversedtitles);
$i = 0;
foreach ($mycourses->children as $coursenode) {
$branch->add($reversedcontent[$i], $reversedactions[$i], $reversedtitles[$i]);
$i++;
}
I've naughtily used 3 arrays where no doubt a multi di array would have done, but my issue was at the bottom when adding them to the branch I was unsure on how to access the necessary data.
The 3 arrays contain info for a course, and they are all in order. When using my multi array I could get the content first, but the next item which should have been content was an action.. etc
If someone could show me how to tidy this up that would be great. Oh and I am pulling content out of an array $mycourses, to put into another array to reverse because $mycourses is the biggest multi di array you've ever seen and I can't use reverse_array on it.