how are you doing? When I use the join() function with duplicated values in an array, the join function returns the array but removing duplicates and I dont want that!
Example:
$array= array(1, 2, 2, 2);
$res = join(',', $array);
I get this:
1,2
but I want the result to be:
1,2,2,2
Hope someone can help me! Thank you
You say this is your code:
while ($coordenada = mysql_fetch_assoc($resultado)) {
$arrayX[$coordenada['ARTICULO']] = $coordenada['ARTICULO'];
$arrayY[$coordenada['CANTIDAD']] = $coordenada['CANTIDAD'];
}
In which case, you are not populating the arrays like you think. Your code is doing this:
$arrayY[1] = 1;
$arrayY[2] = 2;
$arrayY[2] = 2;
$arrayY[2] = 2;
So only contains 2 values. If you want duplicates, change your code to this:
while ($coordenada = mysql_fetch_assoc($resultado)) {
$arrayX[] = $coordenada['ARTICULO'];
$arrayY[] = $coordenada['CANTIDAD'];
}
use implode: implode(',', $array)
even though join is just an alias of implode, it is the proper function to use