1. Go to this page and download the library: Download yarri/link-finder 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/ */
yarri / link-finder example snippets
$text = '
Welcome at www.example.com!
Contact us on [email protected].
';
$lf = new LinkFinder();
echo $lf->process($text);
// Welcome at <a href="https://www.example.com/">www.example.com</a>!
// Contact us on <a href="mailto:[email protected]">[email protected]</a>.
$lf = new LinkFinder([
"attrs" => ["class" => "external-link", "target" => "_blank", "rel" => "nofollow"],
"mailto_attrs" => ["class" => "external-email"]
]);
echo $lf->process($text);
// Welcome at <a class="external-link" href="https://www.example.com/" target="_blank" rel="nofollow">www.example.com</a>!
// Contact us on <a class="external-email" href="mailto:[email protected]">[email protected]</a>.
$text = '
Find more at
<http://www.ourstore.com/>
';
$lf = new LinkFinder();
echo $lf->process($text);
// Find more at
// <<a href="http://www.ourstore.com/">http://www.ourstore.com/</a>>
$html_document = '
<p>
Visit <a href="http://www.ckrumlov.info/">Cesky Krumlov</a> or Prague.eu.
</p>
';
$lf = new LinkFinder();
echo $lf->processHtml($html_document);
// <p>
// Visit <a href="http://www.ckrumlov.info/">Cesky Krumlov</a> or <a href="https://Prague.eu">Prague.eu</a>.
// </p>
echo $lf->processHtml($html_document,["avoid_headlines" => false]);
// or
$lf = new LinkFinder(["avoid_headlines" => false]);
echo $lf->processHtml($html_document);
$lf = new LinkFinder([
"prefer_https" => false,
"secured_websites" => [
"example.com",
"webmail.example.com"
]
]);
echo $lf->process('Please, sign in at example.com/login/ or webmail.example.com');
// Please, sign in at <a href="https://example.com/login/">example.com/login/</a> or <a href="https://webmail.example.com">webmail.example.com</a>
$lf = new LinkFinder(["shorten_long_urls" => false]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.