Career

php tip

$str = “home::khanhpt::test.tar.gz”;
$data = explode(“::”,$str);
$data[0] = “root”;
$name = join(“::”,$data);
echo $name;

You could use a regular express to remove everything apart from those characters you wish to keep:
$string=preg_replace('/[^A-Za-z0-9 _-+&]/','',$string);

Replaces everything that is not (^) the letters A-Z or a-z, the numbers 0-9, space, underscore, hypen, plus and ampersand – with nothing (i.e. remove it).

cái này giờ mới biết, tiện ghê, há há, ghi lại kẻo quên, sau này có gì tìm lại cho dễ😀

hehe

2 thoughts on “php tip

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s