Im not soo comfortable in algorithms can somebody please help me to convert this for loop to a foreach please
for($i = 0; $i < count($cartBookItems); $i++) {
$currentCartBookItem = $cartBookItems[$i];
if($currentCartBookItem->getBookID() == $book->getId()) {
$newQuantity = $currentCartBookItem->getQuantity() + $quantity;
$currentCartBookItem->setQuantity($newQuantity);
$isItemAlreadyExists = true;
}
}