2

I want to store multiple product IDs from my database into one variable.

Ex: store (01, 02, 03 from database) into $productid and when I get $productid to show it should be displayed like this:

<p>Product ID : <?php echo $productid; ?></p>

Product ID : 01, 02, 03

1 Answer 1

2

You can use PHP's join() function:

$productid = join(', ', $items)
Sign up to request clarification or add additional context in comments.

2 Comments

can you tell how to store product id from database to one variable? i don't know how to do that.
In the example you removed from your question, you added all ID's from the database into the array $items. If you put this line underneath that loop, you join all the items from that array into 1 string, separated by a comma and a space.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.