How to use a variable as a className inside preg_match_all parameters?

Question

I am using regular expression to get the text inside a single p tag targeting its class. the problem is I want to use a php variable as class name and use a loop to change the class name each time.

$sample = get_the_content(); 


<button class="accordion">
preg_match('/<strong class="1">(.*?)</strong>/s', $sample, $match); 
echo $match[1]; 


$className = "1";

I want to use the $classname varialbe up there and increment it in a loop to get different paragraph content each time.

I hope I am clear in my question.

0
Ashur 2 years 2020-01-11T08:38:42-05:00 0 Answers 67 views 0

Leave an answer

Browse
Browse