I have one string format in that remove unwanted characters and taken time format only my string is 10:02:in(user)
in that remove all the characters and taken 10:02 only how?
Asked
Active
Viewed 51 times
1

rajsree
- 41
- 8
-
1Possible duplicate of [Get first n characters of a string](http://stackoverflow.com/questions/3161816/get-first-n-characters-of-a-string) – Stephen Rauch Feb 07 '17 at 05:09
3 Answers
0
try using substr
$myStr = "10:02:in(user)";
echo $result = substr($myStr, 0, 5);

Shibon
- 1,552
- 2
- 9
- 20
0
The explode() function is used to split a string.
Syntax :
explode(delimiter, string_name, limit)
<?php
$str = "10:02:in(user)";
$new = explode(":", $str);
echo $new[0].":".$new[1];
?>

Aman Kumar
- 4,533
- 3
- 18
- 40