I'm new to php and would like to know how to make the following possible ...
Below I have several arrays populated from Database rows. Id like to have a new array mappingId that concatenates several rows to form the value for the mappingId array. Below I have used array_combine but this doesn't seem to work. Can anyone advise on what to use?
$appId = array();
$appDate = array();
$appTime = array();
$appDoctorId = array();
$mappingId = array(); // combined values
for ($i = 0; $i < mysqli_num_rows($resultAppointmentsBooked); $i++)
{
$row = mysqli_fetch_row($resultAppointmentsBooked);
$appId = $row[0];
$ids[] = $row[0];
$appTime[] = $row[3];
$appDate[] = $row[4];
$appDoctorId[] = $row[2];
$mappingId = array_combine($row[4], $row[3], $row[2]);
//Test output
echo "MappingId: $row[4]$row[3]$row[2] <br />";
echo "MappingId2: - $mappingId[$i] <br />";
}
I have also used 'array_merge' the following way ...
$ids[] = $row[0];
$appTime[] = $row[3];
$appDate[] = $row[4];
$appDoctorId[] = $row[2];
$mappingId = array_merge($appDate, $appTime, $appDoctorId);
but when I print the values ...
echo "MappingId2: $mappingId[$i] <br />";
It only output the value of the first array.
$mappingIdhold the data?$resultAppointmentsBookedand how you want to structure$mappingId?appDate+appTime+appDoctorIdmean? Do you want those value with a+sign or something like thisappDate apTime appDoctorId? Please let me know. Check my answer!