PHP read everything until first comma -


i have string this:

$string = "hello, my, name, is, az";   

now wanna echo whatever there before first comma. have been using following:

echo strstr($this->tags, ',', true); 

and has been working great, problem works php 5.3.0 , above. on php 5.2.

i know achieve through regular express pregmatch suck @ re.

can me this.

regards,

<?php  $string = "hello, my, name, is, az"; echo substr($string, 0, strpos($string, ',')); 

you can (and should) add further checks avoid substr if there's no , in string.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

What is the difference between data design and data model(ERD) -

ios - Can NSManagedObject conform to NSCoding -