How does this get the value

Source: Internet
Author: User
String ' think:["AAA", "BBB"] '
What do I have to do with the AAA and BBB inside?


Reply to discussion (solution)

SUBSTR () function own Baidu

Always Follow blogs: http://www.phpthinking.com/

SUBSTR () function own Baidu

Always Follow blogs: http://www.phpthinking.com/

Is the length of the AAA and BBB fixed? The substr () on the upper floor is available.

Substr

$s = ' think:[' aaa, ' BBB ' ';p reg_match_all ('/' (. +?) ' /', $s, $m);p rint_r ($m [1]);

I think it's better to use SUBSTR.

In fact, it can be sorted into JSON can be interpreted format, and then json_decode to get the array.

$str = ' think:[' "AAA", "BBB"] '; $str = ' {'. $str. '} '; $str = Preg_replace ('/(\w+):/is ', ' "$": ', $str); $result = Json_decode ( $str, True);p rint_r ($result [' think ']);


Array
(
[0] = AAA
[1] = BBB
)
  • 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: info-contact@alibabacloud.com 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.