$arraycontent = explode('<p>##SEPERATOR##</p>', $text);
Nov 9, 2021
8
Level 5
Split the string to array based on seperator
i have a html editor and i have a data like below,
<p>Author Name, Department</p>
<p>##SEPERATOR##</p>
<p>Author Name, Department</p>
<p>##SEPERATOR##</p>
<p>Author Name, Department</p>
<p>##SEPERATOR##</p>
<p>Author Name, Department</p>
Here i am trying to explode above data using the separator ##SEPERATOR## keyword.
i have a code like below,
$arraycontent = explode('##SEPERATOR##', $text);
dd($arraycontent);
Above code is working fine but it is not removing the <p></p> between the separator.
the response is like below,
array:4 [▼
0 => "<p>Author Name, Department</p><p>"
1 => "</p><p>Author Name, Department</p><p>"
2 => "</p><p>Author Name, Department</p><p>"
3 => "</p><p>Author Name, Department</p>"
]
Here at 0 index <p> tag is opening and at index 1 </p> tag is closing i want to strip this one too in explode. how to do this? so that response should be like below,
array:4 [▼
0 => "<p>Author Name, Department</p>"
1 => "<p>Author Name, Department</p>"
2 => "<p>Author Name, Department</p>"
3 => "<p>Author Name, Department</p>"
]
Level 6
Really?
Try this:
$arraycontent = explode('<p>##SEPERATOR##</p>', $text);
dd($arraycontent);
Please or to participate in this conversation.