Is there any way to pass string variable to array() function:
$ints = '112233,112234';
$arr = array($ints);
//instead of
$arr = array(112233,112234);
I know that there are plenty other ways, but passing the string is my only option:
$stArr = array();
foreach($dataTeacherAssWr[0]->getStudents() as $student) {
$stArr[] = $student->getIdUser();
}
MyCacheManager::clearAssignmentCacheOnHomepageForUsers($_SESSION['id_user'], $stArr);
and the method:
public static function clearAssignmentCacheOnHomepageForUsers($teacherId, $studentId) {
return self::clearAssignmentCacheOnHomepage(
Array(
'teacherIds' => array($teacherId),
'studentIds' => array($studentId)
)
);
}
as you can see I can pass $studentId as "flat" ids in string
array()
is a language construct not a function, and you might misinterpret it's usage if you look at it as a function. – Yoshi Nov 16 '12 at 9:34'teacherIds' => array($teacherId);
with'teacherIds' => explode(',',$teacherId);
and the same for'studentIds' => ...
... so you don't have to usearray();
– Maccath Nov 16 '12 at 16:39