PHP date function
For example, I want date in this format
Use format string "Y-m-d"
preg_match
format.
preg_match('/line1\r\ntheme_name:([\s\S]*?)\r\nline3/', $text, $matches);
The matches ...
Match text between two lines, suppose we have three lines of text
line1
theme_name:theme1 ...
line3
We want to extract out the theme name, here the "theme1" string. We use windows line ending ... will looks like
Array ( [0] => line1 theme_name:theme1 line3 [1] => theme1 )
preg_match_all
Here is a sample html file contains only "p" and "div" tag:
And we want to insert content into the html, we don't want undermine the html structure, we wish to delimit it in terms of html element, not just characters. We also want to know the positions we want to insert the content. We can use PREG_OFFSET_CAPTURE: