Note that there are some explanatory texts on larger screens.

plurals
  1. POIf there a PHP function like ucfirst() that will ignore html?
    primarykey
    data
    text
    <p>I am programmatically cleaning up some basic grammar in comments and other user submitted content. Capitalizing I, the first letter of sentence, etc. The comments and content are mixed with HTML as users have some options in formatting their text.</p> <p>This is actually proving to bit a bit more challenging than expected, especially to someone new to PHP and regex.</p> <p>If there a function like ucfirst that will ignore html to help capitalize sentences?</p> <p>Also, any links or tutorials on cleaning up text like this in html, would be appreciated. Please leave anything you feel would help in the comments. thanks!</p> <p>EDIT: Sample Text:</p> <pre><code>&lt;div&gt;&lt;p&gt;i wuz walkin thru the PaRK and found &lt;strong&gt;ur dog&lt;/strong&gt;. &lt;br /&gt;i hoPe to get a reward.&lt;br /&gt; plz call or text 7zero4 8two8 49 sevenseven&lt;/div&gt; </code></pre> <p>I need for it to be (ultimately)</p> <pre><code>&lt;div&gt;&lt;p&gt;I was walking through the park and found &lt;strong&gt;your dog&lt;strong&gt;. &lt;p&gt;I hope to get a reward.&lt;/p&gt;&lt;p&gt; Please call or text (704) 828-4977.&lt;/p&gt; </code></pre> <p>I know this is going a little farther than the intended question, but my thought was to do this incrementally. ucfirst() is just one of many functions I was using to do one small cleanup at a time per scan. Even if I had to run the text 100 times through the filter, this runs on a cron run when the site has no traffic. I wish there was a discussion forum where this could continue as obviously there would be some great ideas on continuing the approach. Any thoughts on how to approach this as an overall project by all means please leave a comment.</p> <p>I guess in the spirit of the question itself. ucfirst then would not be the best function for this as it could not take an argument list of things to ignore. A flag IGNORE_HTML would be great!</p> <p>Given this is a PHP question, then the DOM parser recommended below sounds like the best answer? Thoughts?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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