awebb
07-07-2003, 01:50 AM
I have a <select> with the <option> created by sorting through some arrays. this works fine but leaves gaps in the <select> which look a bit strange when they get big.
The <option> is a date, used in a booking process.
Is there a way of filling in these gaps with a single word like "Booked"?
I have read about array_push(), but this only seems to add to the end of an array and what I seem to need is something to fill in the gaps. Maybe something like:
$booked="Booked";
if ($select_date[$i]==""){
$select_date[$i]=$booked;
}
or even an array that contains the word "Booked" as many times as needed (never more than 100).
I can't quite figure out how to get this to work or where to put the code.
Any suggestions gratefully recieved.
Here is how I am sorting the arrays (it might be ugly but it works):
$existing1[]=array($existing1);
$existing2[]=array($existing2);
$existing3[]=array($existing3);
$existing4[]=array($existing4);
$existing=array_merge($existing1, $existing2, $existing3, $existing4);/*creates the definitive existing array*/
$existing=array_unique($existing);/* removes duplicates */
$option2_date[]=$option_date;
$select_date=array_diff($option2_date,$existing);/* subtracts the existing dates from the selected dates */
$select_date=array_unique($select_date);/* removes any posible duplicates */
for ($i=0;$i<=100;$i++)
{
echo"<option value=\"$select_date[$i]\">$select_date[$i]<br /></option>";
}
The <option> is a date, used in a booking process.
Is there a way of filling in these gaps with a single word like "Booked"?
I have read about array_push(), but this only seems to add to the end of an array and what I seem to need is something to fill in the gaps. Maybe something like:
$booked="Booked";
if ($select_date[$i]==""){
$select_date[$i]=$booked;
}
or even an array that contains the word "Booked" as many times as needed (never more than 100).
I can't quite figure out how to get this to work or where to put the code.
Any suggestions gratefully recieved.
Here is how I am sorting the arrays (it might be ugly but it works):
$existing1[]=array($existing1);
$existing2[]=array($existing2);
$existing3[]=array($existing3);
$existing4[]=array($existing4);
$existing=array_merge($existing1, $existing2, $existing3, $existing4);/*creates the definitive existing array*/
$existing=array_unique($existing);/* removes duplicates */
$option2_date[]=$option_date;
$select_date=array_diff($option2_date,$existing);/* subtracts the existing dates from the selected dates */
$select_date=array_unique($select_date);/* removes any posible duplicates */
for ($i=0;$i<=100;$i++)
{
echo"<option value=\"$select_date[$i]\">$select_date[$i]<br /></option>";
}