-1

I need to insert only a HTTP in a list of links (10,000) that doesn't have one, for exemple

<a href="nunm-press.com">

From

<a href="nunm-press.com"
to
<a href="http://nunm-press.com"

Suggestions?

I search for "str_replace replace only if doesn't exist", found nothing.

2 Answers 2

1

I dont exactly understand your question but if you are using php and you want to set http or https you can try this.

$url = 'nunm-press.com';
$parsed_url = parse_url($url);
if (!isset($parsed_url['scheme'])) {
    $url = 'http://' . $url;
}
echo '<a href="' . $url . '">Link</a>';
Sign up to request clarification or add additional context in comments.

Comments

0

you can use str_replace function

<?php
$string='<a href="nunm-press.com">';
$string_replace=str_replace('href="','href=\"http://',$string);
echo $string.' >> '.$string_replace;
?>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.