title: str_replace in post_content with increment value using php
body: <pre><code>$selected_publications = $post-&gt;post_content;
  
  $ii = 0;
  
  $getLi = array("&lt;li&gt;","&lt;/li&gt;");
  
  $replaceLi   = array("&lt;li&gt;&lt;div&gt;$ii&lt;/div&gt;&lt;p&gt;","&lt;/p&gt;&lt;/li&gt;"); 
  
  $selectedPublications = str_replace($getLi, $replaceLi, $selected_publications);
  
  echo $selectedPublications;
  </code></pre>
  
  <p>There has uncountable li tag for this reason this loop <code>for($ii=0; $ii &lt;= 10; $ii++)</code> is limited for 10 li tag, I think that If li tag 5 , it will loop 5 times. if 15 li tag , it will 15 times loop. I think <code>for($ii=0; $ii &lt;= 10; $ii++)</code> is not actual solution for my problem.</p>