I have a List of (integer)ID's, which i am storing as text, like
23;45;67;12;332;783;123;33;15;87;41;422;88;58;
now i am working with PHP, i want to check if a particular ID already exists in that TEXT, i have the explode function, which can give me an array of numbers, and then i can use the in_array function, alternatively i can just use the strpos function to find in text.
so which one will be more efficient accourding to you ?
Thanks a lot for taking time to read this.
If all you have to do is look up a single ID, then strpos()
will be more efficient, because all it has to do is find an occurrence of id;
, whereas explode()
will do a lot more than that, not to mention the costly call to in_array()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With