Extracting all values between curly braces regex php

前端 未结 3 1416
醉酒成梦
醉酒成梦 2020-11-28 13:22

I have content in this form

$content =\"

This is a sample text where {123456} and {7894560} [\'These are samples\']{145789}

\";
3条回答
  •  有刺的猬
    2020-11-28 14:10

    Do like this...

    This is a sample text where {123456} and {7894560} ['These are samples']{145789}

    "; preg_match_all('/{(.*?)}/', $content, $matches); print_r(array_map('intval',$matches[1]));

    OUTPUT :

    Array
    (
        [0] => 123456
        [1] => 7894560
        [2] => 145789
    )
    

提交回复
热议问题