If in_array not working

I have an array that is exploded and imploded and all is fine using it, but I needed to change the output of a list so that all the list showed but if it was in the array there was a link around it, all pretty straight forward, but for some reason its not reading the value array and comparing it with the ID inside while

$query  = "select Corporations from UserAdmin WHERE ID = $cID AND (Active=1)";
$result2 = mysql_query($query);
$rowu = mysql_fetch_array($result2, MYSQL_ASSOC); 
$corpIDs = explode(";",$rowu['Corporations']);
$acorps = implode(',', $corpIDs); ?>

<div class="box-content" style="width:500px;">
<ul style="position:relative; left:28px; font-size:13px; padding-top:5px; list-style-type:decimal">
<?php $q=("select * from Corporations  ORDER BY ID");
$result = mysql_query($q) or die(mysql_error());
$a=mysql_query("select count(User) as total1 from Documents WHERE (Corporation=$g[ID]) AND User IN (".$cID.") AND (Active=1)");
$string = $g['ID'];
$array  = $acorps;

echo $string;
echo $array;

if ( ! in_array( $string, $array ) )
{ ?>
    <li>php echo $g['Name']?></li>
<? }  else { ?>
 <li ><a href="main.php?corpID=<?php echo $g['ID']?>" title="<?php echo $g['Name']?>"><?php echo $g['Name']?></a> <!--[<?php echo $data['total1']; ?>]--></li>
<? } ?>
<?php } ?>

When I echo $string and $array out the values are correct, string being the id of the value in the list and $array being the imploded array

The echo of the array comes out like this on the page I am on.


and echo of string


and so on with that one as it goes through the loop


I gather from your previous thread that the IDs are stored as a string

The problem is that here you’re exploding the string to an array ($corpIDs) and then imploding that array back to a string ($acorps):

$corpIDs = explode(";",$rowu['Corporations']);
$acorps = implode(',', $corpIDs);

then you’re trying to pass the string to in_array as if it was an array:

$array  = $acorps;

echo $string;
echo $array;

if ( ! in_array( $string, $array ) )

it looks like you want to be using $corpIDs, not $acorps.