Hi there.
Hi there, I am just trying to use implode function to join the values together.
In the table field I have values stored as:
ProductIDField
|40|38|39|
And these values are separated by |.
Now I’d like to add(concatenate) a new ID eg 54 to it. To store in the table as:
ProductIDField
|40|38|39|54|
But to add 54, I must first separate the existing values using the explode function. I retrieve the existing values into an array variable called:
$ProductInfo[productId];
Now I explode them into variable to separate | from the values.
$currentPrdIds[] = explode("|", $ProductInfo[productId]);
And when we view the values of $currentPrdIds, we get:
print($currentPrdIds);
Array ([0] => Array ( [0] => [1] => 40 [2] => 38 [3] => 39))
All is Good. Now to add 54 to it, which is stored in $myPrdID variable. I am Simply typing:
$currentIds[] = implode("|",$currentPrdIds) . "|" . $myPrdID ;
This should give:
|40|38|39|54|
But I’m getting stuck here. It is not joining 54 to the existing values.
Please see if there is any missing step here. I am stuck at the last stage to use implode() function to join array values to a new one.
Please see whats the missing ingredient here. Or is there anything else we should do here.
All Comments and feedbacks are always welcomed! ![]()
Thank you!