Today I am learning php programming and I am dabbling with arrays, doing an exercise where I am asked to create an array and pass keys and values to that array and then display them. So far I have worked out this code, but I don't really understand how I could pass a key and a value with the method array_push
to a array
.
I attach my code block
// Crear una función la cual agregue un array con su respectiva clave y valor
function vehicle_sale ($aa,$ab,$ac,$ad){
$vehicle = [];
array_push($vehicle,$aa,$ab,$ac,$ad);
foreach($vehicle as $vehiculo => $cantidad){
echo "Los vehiculos son los siguientes: $vehiculo y la cantidad de venta dde este vehiculo es $cantidad <br>";
}
};
vehicle_sale('toyota','chevrolet','honda','wolsvangen');