This is my function with a foreach:
$InsertData = function($getQuery) use($localLink, $tableTelephoneNumber)
{
$data = GetData($getQuery);
foreach ($data['data'] as $value)
{
$insertQuery = "INSERT INTO $tableTelephoneNumber (TelephoneNumber, DeliveryContractId) VALUES ('$value->Number__c','". $value->DeliveryContract__r->Id ."')";
mysqli_query($localLink, $insertQuery);
}
}
As you can see i use $value
in my $insertQuery
variable. The problem i have is that i want to declare and pass $insertQuery
to the function from outside but i want it to keep using $value
which is inside the foreach. Is this possible in PHP 7?