0
I need to take the last 14 characters of a relation of urls inside a . txt
$url = file_get_contents('https://www.site.com.br/relacao.txt');
In relation.txt I have:
www.site.com.br/aluno/s/francisco-augusto/11111111111111
www.site.com.br/aluno/s/francisco-fernandes/11111111111112
www.site.com.br/aluno/s/francisco-ocario/11111111111113
www.site.com.br/aluno/s/giselia-augusto/11111111111114
www.site.com.br/aluno/s/giselia-fernandes/11111111111115
Etc.. (várias outras)
And I would like to put it as follows: (only with the latest figures)
11111111111111
11111111111112
11111111111113
11111111111114
11111111111115
Etc...
I’ve tried so many ways.
$url = preg_replace("/[^0-9]/", " ", $url);
But the result is as follows:
11111111111111 11111111111112 1111111111113 11111111111114 etc
.
I need each number on one line.
Can someone help me?
Function buscaFinal($line) { $var = substr($line,(strlen($line)-14),strlen($line); echo $var; php_eol; } $url = file_get_contents('https://www.site.com.br/relaca.txt'); $number = searchFinal($url); echo $numero; Returns only the first number of the relation.
– Marcelo
But then you have to read the
txt
and go playing the line you are reading. I considered that you are already reading yourtxt
. Click on edit in your question and post all your code, so I can make an example in it.– rbz
So, I have a.txt relationship with thousands of urls inside. (as stated in the question) I need to access the.txt relation get all urls and then print ONLY the last 14 characters. per line (as mentioned in the question)
– Marcelo
But you say "But the result is as follows:", so it is understood that you are already accessing the txt and have it printed correctly? Then post the part that reads the txt, and the loop that you use to print the content. It is not the txt content that is to post.
– rbz
I don’t think I understand... $url = file_get_contents('https://www.site.com.br/relacao.txt'); // here do I access the right content? if I echo at $url I have: www.site.com.br/student/s/francisco-August/11111111111111 (and several other urls) I need: when printing the result it just shows (of all urls) the last 14 numbers.
– Marcelo
So your return is not
11111111111111 11111111111112 1111111111113 11111111111114
as in the question. This is not how you use thefile_get_contents
.– rbz
I will open a chat if you need to continue the issue, as it has already extended the comments.
– rbz