Note that there are some explanatory texts on larger screens.

plurals
  1. POReturn value without numeric and punctuations
    primarykey
    data
    text
    <p>I'm trying to strip the numeric and punctuations from a string leaving only alpha characters in SIMPLE HTML DOM, with no success I've tried multiple approaches and just can't get it! </p> <p>Example string: The Amazing Retard (2012) #1 Output string: The Amazing Retard</p> <p>I understand it's for an undefined method and I've looked at multiple pages for this, however I'm brain farting for how to include the method. Any help would be appreciated. The error that I get is </p> <p>Fatal error: Call to undefined method simple_html_dom_node::preg_replace() in /home/<strong>**/public_html/wp-content/themes/*<em></strong>/</em>***.php on line 123</p> <p>The code is as follows:</p> <pre><code>&lt;?php function scraping_comic() { // create HTML DOM $html = file_get_html('http://page-to-scrape.com'); // get block foreach($html-&gt;find('li.browse_result') as $article) { // get title $item['title'] = trim($article-&gt;find('h4', 0)-&gt;find('span',0)-&gt;outertext); // get title url $item['title_url'] = trim($article-&gt;find('h4', 0)-&gt;find('a.grid-hidden',0)-&gt;href); // get image $item['image_url'] = trim($article-&gt;find('img.main_thumb',0)-&gt;src); // get details $item['details'] = trim($article-&gt;find('p.browse_result_description_release', 0)-&gt;plaintext); // get sale info $item['on_sale'] = trim($article-&gt;find('.browse_comics_release_dates', 0)-&gt;plaintext); // strip numbers and punctuations $item['title2'] = trim($article-&gt;find('h4',0)-&gt;find('span',0)-&gt;preg_replace("/[^A-Za-z]/","",$item['title2'], 0)-&gt;plaintext); $ret[] = $item; } // clean up memory $html-&gt;clear(); unset($html); return $ret; } // ----------------------------------------------------------------------------- $ret = scraping_comic(); if ( ! empty($ret)) { $scrape = 'http://the-domain.com'; foreach($ret as $v) { echo '&lt;p&gt;'.$v['title2'].'&lt;/p&gt;'; echo '&lt;p&gt;&lt;a href="'.$scrape.$v['title_url'].'"&gt;'.$v['title'].'&lt;/a&gt;&lt;/p&gt;'; echo '&lt;p&gt;&lt;img src="'.$v['image_url'].'"&gt;&lt;/p&gt;'; echo '&lt;p&gt;'.$v['details'].'&lt;/p&gt;'; echo '&lt;p&gt; '.$v['on_sale'].'&lt;/p&gt;'; } } else { echo 'Could not scrape site!'; } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    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