get number in front of 'underscore' with php

前端 未结 3 1660
轮回少年
轮回少年 2021-01-13 15:22

I have this:

15_some_text_or_numbers;

I want to get whats in front of the first underscore. There is always a letter directly after the fir

3条回答
  •  抹茶落季
    2021-01-13 15:43

    Simpler than a regex:

    $x = '14_hello_world';
    $split = explode('_', $x);
    echo $split[0];
    

    Outputs 14.

提交回复
热议问题