0
I have two arrays
in php
, which I compare and create a third and want to print this difference on a list.
I’ve tried the foreach
, but this method prints a huge list in string
.
This is my code:
$sql = mysqli_query($cx, "SELECT IPS FROM ipvalidos ORDER BY IPS ASC ");
while($aux = mysqli_fetch_assoc($sql)) {
$arrayip[ ] = $aux["IPS"];
}
$diferenca = array_diff($arrayip, $arraycompara);
foreach ($diferenca as $diferencas)
{
$stringArrayF = $stringArrayF.$diferencas;
}
echo $stringArrayF;
The printed result comes out:
192.168.0.1192.168.0.2192.168.0.3192.168.0.4192.168.0.5...
I wish I could put that result into one select html
<select><option value="$stringArrayF">$stringArrayF</option>;
Fixed kkk again , now go
– Vitor
It got better! But it stayed that way
<select>
<option value="192.168.0.100">192.168.0.100</option> 
<option value="192.168.0.100192.168.0.104">192.168.0.100192.168.0.104</option> 
<option value="192.168.0.100192.168.0.104192.168.0.105">192.168.0.100192.168.0.104192.168.0.105</option> 
</select>
The problem is separating the results of _ array_ by position.– Anderson Fidelis
declare that i = 0 , in which case we could in value exchange for an i++, type option value = $difca for option value = $i; i++ understood ?
– Vitor
I believe it has more to do with printing each position separately, I think the iteration, with a for wouldn’t do that in the <select> It would have to be somewhere else :/. I just don’t know where
– Anderson Fidelis