my html tag is <div class="address"><h3>Vincent B. Davis</h3> . I will grab Vincent B. Davis string. How i can get this? sorry for my bad english.
            Asked
            
        
        
            Active
            
        
            Viewed 64 times
        
    0
            
            
         
    
    
        Janu Yoga
        
- 1
- 5
- 
                    You can do this without regex. I'd like to say use "strip_tags" for this one but it's better to use the DOMDocument instead of regex for parsing HTML. – Debflav Jun 27 '17 at 07:54
- 
                    You could use DOM parser: http://nimishprabhu.com/top-10-best-usage-examples-php-simple-html-dom-parser.html – Denis Solakovic Jun 27 '17 at 07:55
- 
                    can i use explode? – Janu Yoga Jun 27 '17 at 07:55
- 
                    @JanuYoga, you may use anything. But the right, proper, valid and optimal way is using XML/HTML parsers – RomanPerekhrest Jun 27 '17 at 07:58
- 
                    solved by using simple_html_dom thanks all – Janu Yoga Jun 27 '17 at 08:05
1 Answers
0
            
            
        If you're talking only about getting the regex:
preg_match("/<div class=\"address\"><h3>(.*)<\/h3>/", '<div class="address">
<h3>Vincent B. Davis</h3></div>', $output_array);
echo $output_array[1];
 
    
    
        C. Sanchez
        
- 76
- 1
- 7