PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?php
function dependencies($aid, $sid){
require_once('components/com_ordre/funksjoner.php');
for($i = 0, $max = count($sid); $i < $max; $i++){
/* Finner hvilke aktiviteter hver sveiseaktivitet er avhengig av */
$this->sekvens = $sid[$i]{1};
echo "Before:".$this->sekvens."<br>";
$filtered = array_filter($aid, array("parser", "callback"));
/* Legger inn avhengigheter for aktuell sveiseaktivitet */
foreach($filtered as $verdi){
db('INSERT INTO #__poly_dependson( `actID1` , `actID2` ) '
. ' SELECT s.actID, t.actID FROM #__poly_orderactivities = s, #__poly_orderactivities = t'
. ' WHERE ( ( s.drumID = '''.$sid[$i].''' AND s.articleID = '''.$this->ID.''' )'
. ' AND ( t.drumID = '''.$verdi.''' AND t.articleID = '''.$this->ID.''' ) )');
}
}
}
function callback($id){
echo "Inside:".$this->sekvens."<br>";
return ($id{1} == $this->sekvens);
}
?>
The variable "sekvens" is a global variable in the class "parser". I set it in the function dependencies but when i access it in the callback-function it's unset. With other words "Before:" prints but "Inside:" doesn't. I can't seem to get around this problem. Anyone know how this can be solved?
I believe, by sending the "parser" name as part of the callback, php creates a new object, then calls the callback function. Try replacing "parser" with &$this