Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $string = '23/CSE/4/2014';
- $array = explode('/', $string);
- echo $array[0]; // 23
- echo $array[1]; // CSE
- echo $array[2]; // 4
- echo $array[3]; // 2014
- $main_string = "23/CSE/4/2014";
- $sub_string = "/CSE/4/2014";
- echo str_replace($sub_string, '', $main_string);
- // 23
- $main_string = "23/CSE/4/2014"; // or "CSE/4/2014/23"
- $sub_string = "CSE/4/2014"; // notice no leading/trailing slash on this value
- echo trim(str_replace($sub_string, '', $main_string), '/'); // leading/trailing slashes are trimmed
- // 23
Add Comment
Please, Sign In to add comment