2012-10-13

CODE - php 字串取代

example :
$path = '/home/nas/webhd_14/e2/c3/10107664/50012/sync/a3/string';
$path = preg_replace('/home\/nas/', 'net', $path);
# output: /net/webhd_14/e2/c3/10107664/50012/sync/a3/string
$str = 'hello.@.@world';
$key = preg_replace(array('/\./', '/\@/'), '_', $str);
# output: hello||||world

沒有留言:

張貼留言