html - How to join multiple numbers together as a string in PHP? -
I need to create a separate string with numbers of commas
The issue I am running is That is, in the end, I am getting the total numbers of all the numbers when it should be:
2, 10, 35, 56, 67 ', etc.
What I'm doing here:
$ field_ids = ''; // loop & lt ;? Php $ field_ids = bp_get_the_profile_field_ids (); ? & Gt; // end while loop // start loop & lt ;? Php $ field_ids + = bp_get_the_profile_field_ids (); ? & Gt; // End Loop & lt; Input type = "hidden" name = "field_ids" id = "field_ids" value = "& lt ;? php echo $ field_ids ;; & gt; & Gt;
How can I get it:
& lt; Input type = "hidden" name = "field_ids" id = "field_ids" value = "2, 10, 35, 56, 67" & gt;
Instead of:
& lt; Input type = "hidden" name = "field_ids" id = "field_ids" value = "170" & gt;
Yes, you can assemble them as an array, then Use implode ()
to do this:
$ field_ids = array (); // Start as an array during start (...) {// loop block $ start during field_ids [] = bp_get_the_profile_field_ids (); // it is pushing inside) // end while loop block $ field_ids = implode (',', $ field_ids); // Compan & amp; Lt;
< By using p> + =
you are constantly adding them to the end of the loop as a result of your completion.
Comments
Post a Comment