Note that there are some explanatory texts on larger screens.

plurals
  1. POTrying to use PHP to remove a line of HTML
    text
    copied!<p>Im trying to remove "Click" out of the code after it has been used. I need it to work in the beginning but after the class="details" is used, i need the code removed. I figured I could use PHP for this?!?!?!</p> <p>I know that I can use PHP to remove the HTML and I have been trying to use the preg_replace() function but its not working. </p> <p>I cant color code the individual lines so i have have place large space about and below the HTML instance i need and also below where the line occurs again, where I need the HTML to be removed.</p> <p>I hope this makes sense. </p> <p>Thank you in advance for all your help.</p> <pre><code>&lt;?php /** * @file */ ?&gt; &lt;div class="cloud-computing-item"&gt; &lt;div class="container"&gt; &lt;div class="item-header"&gt; &lt;h3&gt; &lt;?php print $company['name'] ?&gt; &lt;/h3&gt; &lt;/div&gt; &lt;div class="item-subheader"&gt; &lt;div class="label"&gt;Services Offered:&lt;/div&gt; &lt;div class="data service-offerings"&gt; &lt;?php foreach($company['services_display'] as $service =&gt; $element){ print $element; } ?&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="item-body"&gt; &lt;div class="overview"&gt; &lt;div class="label"&gt;Cloud Providers:&lt;/div&gt; &lt;div class="data"&gt; &lt;?php foreach(array_slice($company['service_providers'], 0, 4) as $provider): ?&gt; &lt;div&gt; &lt;?php print $provider; ?&gt; &lt;/div&gt; &lt;?php endforeach; ?&gt; &lt;div style="color:#000099;font-weight:bold;"&gt;Click&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="details"&gt; &lt;?php $str = '&lt;div style="color:#000099;font-weight:bold;"&gt;Click&lt;/div&gt;'; $result = preg_replace('(&lt;style="color:#000099;font-weight:bold;"&gt;).*?(&lt;/div&gt;)','$1$2',$str); var_dump($result); ?&gt; &lt;?php foreach(array_slice($company['service_providers'], 4) as $provider): ?&gt; &lt;div&gt; &lt;?php print $provider; ?&gt; &lt;/div&gt; &lt;?php endforeach; ?&gt; &lt;?php print theme('cloud_computing_item_details', array('company' =&gt; $company)); ?&gt; &lt;/div&gt; &lt;/div&gt; &lt;div style="clear: both; height: 5px;"&gt;&amp;nbsp;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload