Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

viktort1t0's avatar

Convert a string to an array and validate each value

I have a form where people can put URLs it can be just one but it also can be a large string of coma separated URLs. How can i validate each of this URLs after separated.

What is the best or most common apporach for this.

0 likes
4 replies
viktort1t0's avatar

i want to validate if each individual url are valids. The data is a string and if found a , then store in an array the string before the , and the string after the , and once that is done i need to go for each this array and validate if it is an url or not.

jlrdw's avatar

Sorry when you said "How can i validate each of this URLs after separated", I thought you were only looking for the validation part. Otherwise I would have mentioned explode.

But the link has a good @bobbybouwmann answer.

How are you storing the data, you may want to store in Json format, or a related table.

Please or to participate in this conversation.