Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

263
Visualizações
PHP Find specific domain link in string

I need to find a url in text starts with domain zippyshare and put it in the var. I know that i must use regular expression but i don't have idea to make it. Lets say that we have 3 links in text

Facebook: https://facebook.com/pumpsquadofficial Instagram: https://instagram.com/pump_squadpl DOWNLOAD MP3: http://www42.zippyshare.com/v/d6LnGjH8/file.html

and i need to find and put this link "www.42.zippyshare.com/v/blahblahblah" into <a href="$link">. Do you have any idea how to make it? Sorry for my english.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Your question is pretty vague... Obviously you can extract the link looking for that domain name:

<?php
$data = <<<LINKS
Facebook: https://facebook.com/pumpsquadofficial Instagram: https://instagram.com/pump_squadpl DOWNLOAD MP3: http://www42.zippyshare.com/v/d6LnGjH8/file.html Some more text
LINKS;
preg_match('~(http://\w+\.zippyshare\.com/[^\s]+)~', $data, $tokens);
echo sprintf('<a href="%s">', $tokens[1]);

The output obviously is:

<a href="http://www42.zippyshare.com/v/d6LnGjH8/file.html">

I think however it makes sense to invest a few moments into the definition of what information you actually can rely on to extract that link. Is the domain really always that zippyshare.com? Or maybe you need to always extract the link following the DOWNLOAD MP3?

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda