}
<?php
+ $current_objective = '';
$count = 0;
$objectives = '';
foreach($userdata as $element => $value){
if (substr($element,0,14) == 'cmi.objectives') {
- preg_match('/.(\d+)./',$element,$matches);
- $element = preg_replace('/.(\d+)./',"_\$1.",$element);
- if ($matches[1] == $count) {
+ $element = preg_replace('/\.(\d+)\./', "_\$1.", $element);
+ preg_match('/\_(\d+)\./', $element, $matches);
+ if (count($matches) > 0 && $current_objective != $matches[1]) {
+ $current_objective = $matches[1];
$count++;
$end = strpos($element,$matches[1])+strlen($matches[1]);
$subelement = substr($element,0,$end);
}
<?php
+ $current_objective = '';
$count = 0;
$objectives = '';
foreach($userdata as $element => $value){
if (substr($element,0,14) == 'cmi.objectives') {
$element = preg_replace('/\.(\d+)\./', "_\$1.", $element);
- preg_match('/_(\d+)\./', $element, $matches);
- if (isset($matches[1]) && $matches[1] == $count) {
+ preg_match('/\_(\d+)\./', $element, $matches);
+ if (count($matches) > 0 && $current_objective != $matches[1]) {
+ $current_objective = $matches[1];
$count++;
$end = strpos($element,$matches[1])+strlen($matches[1]);
$subelement = substr($element,0,$end);
}
<?php
+ $current_objective = '';
$count = 0;
$objectives = '';
foreach($userdata as $element => $value){
if (substr($element,0,14) == 'cmi.objectives') {
$element = preg_replace('/\.(\d+)\./', "_\$1.", $element);
- preg_match('/_(\d+)\./', $element, $matches);
- if (isset($matches[1]) && $matches[1] == $count) {
+ preg_match('/\_(\d+)\./', $element, $matches);
+ if (count($matches) > 0 && $current_objective != $matches[1]) {
+ $current_objective = $matches[1];
$count++;
$end = strpos($element,$matches[1])+strlen($matches[1]);
$subelement = substr($element,0,$end);
if (isset($track->timemodified) && ($track->timemodified > $usertrack->timemodified)) {
$usertrack->timemodified = $track->timemodified;
}
- }
+ }
+ ksort($userdata);
return $usertrack;
} else {
return false;