I think I figured out how to convert an array into a string and use the string in a query... I have an array with over 40 options on a multi-select drop down list that I want to pass from a form using post to use in a query. When I do it I end up with too many commas and it fails. Here's what I've got..
<?php
echo "You selected ".count($display)." for your search";
if (count($display)==1)
{
for($i=0;$i {
$display3 = $display[$i]."";
echo $display3;
}
}
else
{
for($i=0;$i {
$display2 = $display[$i].",";
$display3 = substr($display2,0,-1);
// I've even tried $display3=eregi_replace(',$', '', $display2);
echo $display3;
}
}
?>
These methods end up removing the commas across the whole string.. Not just the one at the end.
What am I doing wrong?