I am trying to import urls from a list of URLS using the explode function.
For example, let's say
<?php
$urls = "http://storage.google.com/gn-0be5doc/da7f835a8c249109e7a1_solr.txt
http://google.com/gn-0be5doc/1660ed76f46bfc2467239e_solr.txt
http://google.com/gn-0be5doc/6dffbff7483625699010_solr.txt
http://google.com/gn-0be5doc/ef246266ee2e857372ae5c73_solr.txt
http://google.com/gn-0be5doc/d0565363ec338567c79b54e6_solr.txt
http://google.com/gn-0be5doc/43bd2d2abd741b2858f2b727_solr.txt
http://google.com/gn-0be5doc/eb289a45e485c38ad3a23bc4726dc_solr.txt";
$url_array = explode (" ", $urls);
?>
Considering that there is no delimeter here, the explode functions returns the whole text together.
Is there a way I can get them separately? Perhaps use end of url as the txt part?
Thanks in advance.
looks like all you need:
$urls = explode( "\n",$urls );
or
$urls = explode( "\r\n", $urls );
if you must you could use http://
If it was a string with out breaks then:
$urls = "http://storage.google.com/gn-0be5doc/da7f835a8c249109e7a1_solr.txthttp://google.com/gn-0be5doc/1660ed76f46bfc2467239e_solr.txthttp://google.com/gn-0be5doc/6dffbff7483625699010_solr.txthttp://google.com/gn-0be5doc/ef246266ee2e857372ae5c73_solr.txt";
$urls = preg_split('@(?=http://)@', $urls);
print_r($urls);
explode not used as it remove the delimiter
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With