Welcome Guest, Not a member yet? Register   Sign In
strstr function
#6

[eluser]PhilTem[/eluser]
Assuming you have a comma only once in your string to search

Code:
$pos_comma = strpos($string_to_search, ',');
$before = substr($string_to_search, 0, $pos_comma - 1);
$after = substr($string_to_search, $pos_comma + 1);

will return everything before the comma (w/o the comma) and after the comma (again w/o the comma)

Edit: Actually this works for more than one comma in your string, but it will split the string according to the position of your first comma. Just to clarify Wink


Messages In This Thread
strstr function - by El Forum - 11-12-2012, 07:49 PM
strstr function - by El Forum - 11-12-2012, 08:07 PM
strstr function - by El Forum - 11-12-2012, 09:11 PM
strstr function - by El Forum - 11-12-2012, 09:18 PM
strstr function - by El Forum - 11-12-2012, 09:29 PM
strstr function - by El Forum - 11-13-2012, 05:18 AM
strstr function - by El Forum - 11-13-2012, 11:15 AM
strstr function - by El Forum - 11-13-2012, 12:26 PM
strstr function - by El Forum - 11-14-2012, 05:56 PM
strstr function - by El Forum - 11-14-2012, 05:56 PM



Theme © iAndrew 2016 - Forum software by © MyBB