PHP code example of hegland / text-parser

1. Go to this page and download the library: Download hegland/text-parser library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hegland / text-parser example snippets


$name = Parser::findOne($text, '"id2">', '<tbody>', '<td>', '</td>');

/*
result = (string) 'Roger Hegland'
*/

$text = '<script>
    let settings = [{value:"6.0",label:"Zimmer"},{value:"125",label:"Wohnflaeche"},{value:"2025",label:"Baujahr"}];
</script>';

$rooms = Parser::findOneBackwards($text, '",label:"Zimmer"', '"');

/*
result = (string) '6.0'
*/

Parser::fO($text, '<td>', '</td>'); // findOne()
Parser::fM($text, '</a>', '<li>', '">'); // findMany()
Parser::bfO($text, '",label:"Zimmer"', '"'); // findOneBackwards()

Parser::findMany($text, '</a>', '<li>', '">' );

/*
result = array
[
    'companylink1',
    'companylink2',
    'companylink3',
    'link1',
    'link2',
    'link3'
]
*/

$text = Parser::findOne($text, '<tbody>', '</tbody>' );
Parser::findMany($text, '</a>', '<li>', '">' );

/*
result = array
[
    'companylink1',
    'companylink2',
    'companylink3',
]
*/