0

I have an associative array, where I need to modify 3 values before sending to the db.

Can somebody assist with the proper syntax for accomplishing this?

$db->setQuery($query);
$rows =$db->loadAssocList();   
foreach ($rows as $row)
{
 [$row['id']] . ' = ' . (int) ++$MaxID, [$row['id']];
 ...........
 ......
}

Here is the print out of the associative array

Array ( [0] => Array ( [id] => 11 [asset_id] => 671 [catid] => 102 [title] => Photo Master Copy [alias] => Photo Master Copy 692 [description] => 
2

Syntax for modifying the array would be something like

$db->setQuery($query);
$rows =$db->loadAssocList();   
foreach ($rows as &$row)  // & to give a reference, not copy, to the row in rows
{
     ++$MaxID;
     $row['id']  =  $row['id'] + $MaxID;  // Add $MaxID to $row[id]
     .... // possibly other modifications?
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.