in php i want to explode string with tag using utf-8 between them, for example, in this text:
$content = \"فهرست اول hi my name is
You can use preg_split
to split the text by a regular expression, then array_filter
to remove empty strings:
$arr = array_filter(preg_split('/(?=.*?<\/heading>)/', $contents), 'strlen');
It won't remove the tag, since it is in a look-ahead
- a group construct that doesn't consume what it matched.
For example:
فهرست اول hi my name is mahdi whats app فهرست دوم how are you
This should return:
array(
[0] => "فهرست اول hi my name is mahdi whats app ",
[1] => "فهرست دوم how are you"
)
You can check this regex online: https://regex101.com/r/ITi7Lh/1
Or, if you prefer, see how PHP parses it: (the link doesn't seem to work on SO, you have to manually paste it): https://en.functions-online.com/preg_split.html?command={"pattern":"\/(?=