I'm not quite sure if this requires a str_replace() function or a regular expression.
I am querying a value that will always have a period in it. IE (test.test1)
I need to get the contents to the right of the period so in that case: test1 becomes the new string..
I looked at substr_replace which may do what I need to do but it uses an absolute value for the string characters/index which isn't ideal.
Remove a section of a string before a period
Moderator: General Moderators
-
dimxasnewfrozen
- Forum Commoner
- Posts: 84
- Joined: Fri Oct 30, 2009 1:21 pm
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Remove a section of a string before a period
Several ways to do it using the string functions to find the position of the period, but here's another:
A string function version:
Code: Select all
array_pop(explode('.', 'test.test1', 2));Code: Select all
$test = 'test.test1';
substr($test, strpos($test, '.')+1);
//or
substr(strchr($test, '.'), 1);mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.