Adjust PHP code Retrieve the DOM from a given URL

Hello ,

im using the following code to Retrieve the DOM from URL all "A" tags and print their HREFs Now my output is contain "A" i dont want its my out is here http://trend.remal.com/parsing.php

i need to clear my out to be only the name after http://twitter.com/namehere

so output print list of "namehere"

    include('simple_html_dom.php');

 // Retrieve the DOM from a given URL
 $html = file_get_html('http://tweepar.com/sa/1/');
 $urls = array();

  foreach ( $html->find('a') as $e )
  {
  // If it's a twitter link
  if ( strpos($e->href, '://twitter.com/') !== false )
  {
    // and we don't have it in the array yet
    if ( ! in_array($urls, $e->href) )
    {
        // add it to our array
        $urls[] = $e->href;
    }
   }
   }

  echo implode('<br>', $urls);

echo $e->href . '<br>';

Answers


Instead of simply using $urls[] = $e->href, use a regex to match the username:

preg_match('~twitter.com/(.+)~', $e->href, $matches);
$urls[] = $matches[1];

Need Your Help

Use .NET BigInteger as bit field

c# .net performance memory biginteger

I would like to use System.Numeric.BigInteger as bit field.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.