Questions about PHP Regular matching to take out data

Source: Internet
Author: User
The following is a partial processing of source code
 ]*?> ' si ', ' ", $exam); $exam = Preg_replace ("'
 
  
   ]*?> ' si ', ' ", $exam);           $exam = Preg_replace ("' 
   
    ]*?> ' si", "", $exam);           $exam = Str_replace ("", "{tr}", $exam);           $exam = Str_replace ("", "{td}", $exam); Remove HTML Markup $exam = Preg_replace ("' <[/!") *?          [^<>]*?> ' si ', ' ", $exam);        Remove whitespace characters $exam = preg_replace ("' ([RN]) [s]+ '", "", $exam);           $exam = Preg_replace ('//', "", $exam);           $exam = Str_replace ("", "" ", $exam);         $exam = Str_replace ("", "" ", $exam);        $exam = Explode (' {tr} ', $exam);               Array_pop ($exam); Print_r ($exam);? >
    

  
 

What I want is to take out the following piece of data into the array, do not know how to write, the first contact with the regular feel do not understand, thank you to the great gods!
[+] = + Number {TD} course {TD} date {TD} TIME {TD} class {TD} Test room {td} Instructor {TD}[20] = 1{td} fluid Dynamics {td}2014-11-0600:00:00.0{td}14:00-16:00 {TD} Civil 122{TD}Ⅲ-209{TD} Sinina {TD}


Reply to discussion (solution)

That's what you're going to do.

Print_r (Array_map (NULL, explode (' {TD} ', $exam []), explode (' {TD} ', $exam [20]));
Array ([    0] = = Array        (            [0] = = number            [1] = 1        )    [1] = = Array        (            [0] + = Course            [ 1] = Fluid mechanics        )    [2] = = Array        (            [0] = = Date            [1] = = 2014-11-0600:00:00.0        )    [3] = > Array        (            [0] = time            [1] = +        )    [4] = = Array        (            [0] = Class            [1] = = Civil 122        )    [5] = = Array        (            [0] = examination room            [1] =>ⅲ-209        )    [6] = = Array        (            [0] + = Instructor 
  [1] = Sinina        )    [7] = =        Array            ([0] = =             [1] = =)         )

It's still like that.
Print_r (Array_combine (Explode (' {TD} ', $exam []), explode (' {TD} ', $exam [20]));
Array (    [number] = 1    [Course] = Fluid mechanics    [Date] = 2014-11-0600:00:00.0    [TIME]    [class] = > Civil 122    [examination Room] =>ⅲ-209    [Instructor] = Sinina    [] =

I think it's the second one. Insert into the template as an array variable thank you, great God.

Moderator, can I ask you a small question? [Date] = 2014-11-0600:00:00.0 This data on the page is not 00:00:00.0 these, can be removed?

$s = ' 2014-11-0600:00:00.0 '; Echo date (' y-m-d ', strtotime ($s)); Echo substr ($s, 0, 10);

Both of these methods can be

Thank you moderator, so dedicated, grateful extremely, this paste end!

  • 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.