I have a php mysql app I am working on. I have a string from a field in mysql and I also have a array from a mysql query. The array has an ID and a Name field. The string is a ~ delimited list of ID (the same ID's from the query. What I am trying to do, is when I explode my string, I want to replace the ID from the string with the Name from the array using the arrays ID to match with the string ID.
Hope this makes sense... here's what I have so far.
// my array:
$query="SELECT * FROM department";
$deptArray = array();
while($row = mysql_fetch_array($result))
$a1 = array($row[department_id] => $row[department_name], $row[department_id]);
$deptArray = array_merge($a1, $deptArray);
//my string so far (not quite working)...
$str = $dealers_type;
$str2 = substr($str, 0, -1);
$data = explode("~",$str2);
foreach($data as $k => $v)
echo $deptArray[$v].' = '.[department_name.'<br>';