1
I’m using a bootstrap tagsinput to insert values in the bd, but the values are being stored in a single string, for example: "256,257,299". I would like these values to be set in an array and look like this: ["256", "257", "299"], ai dou um foreach e cada valor vai para sua devido lugar no bd. As of today, all in a single string only the first id is being sent to the bd.
Does anyone know how to perform this procedure?
This is my input:
<input type="text" id="taginput" data-role="tagsinput" name="idrelacionado[]">
Grateful for the attention!
Have you thought about using the
split()
?– Giovane
The split is not obsolete? , The bootstrap also indicates to use this way: <select Multiple data-role="tagsinput" name="idrelacionado[]></select>. I’ve tested and met my need, but I don’t know if it’s the right way.
– Mario Barreto
why the
split
would that be obsolete? The bootstrap indicates to do so, but does not deliver in an array format, but rather an easier format for you to transform the value into an array using thesplit
– Giovane
In php.net it says that this function is obsolete in version 5.3.0 and has been removed from version 7. Here are other alternatives to use.
– Mario Barreto
Ah, I thought we were talking about Javascript. I can’t help but since the documentation says it’s obsolete, see what alternative it gives you.
– Giovane
Funny that on the tagsinput page - Bootstrap says that using this select Multiple the values will be set in an array, as you can see: Use the <select Multiple /> as your input element for a tags input, to Gain true multivalue support. Instead of a comma separated string, the values will be set in an array. Existing <option /> Elements will Automatically be set the tags. This makes it also possible to create tags containing a comma.
– Mario Barreto