Character-to-intercept related issues

Source: Internet
Author: User
character to intercept problem!
Suppose the string $a=123/frew/4214/fsdf/123/123/dsa; $a is a variable and the content changes.
So, how to intercept the second "/" from the beginning to the bottom, i.e. 123/frew/4214/fsdf/123/
Do not start the number "/" from the front because you are not sure that there are several '/' in front of you, since you know the contents of the second '/' after the next number.

$t = explode ('/', $a);
echo join ('/', Array_slice ($t, 0,-2)). '/';
PHP Code
$a = ' 123/FREW/4214/FSDF/123/123/DSA '; $t = explode ('/', $a); Echo join ('/', Array_slice ($t, 0,-2)). '/';
$a = explode ('/', $a);
$s [count ($s)-1] Try It
$b = Join ('/', Array_slice ($t, 0,-2)). '/';

Hey, is the 6 floor a joke?
$a = ' 123/FREW/4214/FSDF/123/123/DSA ';
$t = explode ('/', $a);
$b =join ('/', Array_slice ($t, 0,-2)). '/';
Echo $b;
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.