Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I need to cut part of string.

original string: somestring.for
after cut: .for
Posted

You may, for instance, write
PHP
$string = 'somestring.for';
$a = preg_split('/\./', $string);
$res = '.' . $a[1];
 
Share this answer
 
Comments
Lubomur 20-Nov-12 15:59pm    
cool
Here are string manipulation function available in PHP: http://php.net/manual/en/ref.strings.php[^].

The one you are looking is for substr[^].
You will probably also need strpos[^] to find the character you want to split the string on.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 20-Nov-12 15:54pm    
Consider the string is cut, a 5. :-)
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900