Ready to get started?Download WordPress


If/else is killing me, something smarter? (2 posts)

  1. Kenneth Jensen
    Posted 4 years ago #

    Hi there

    Im kinda new to both WordPress and PHP, so this is kinda uphill right now. I managed to do a if-elseif-else that works perfectly, but now im stuck with some more advanced stuff.

    I have a field called ArticleLink. This contains a url either starting with http://, http://www., both or none of them.

    What I would like is a function to do at check and make the outcome a valid url starting with http://www. regardless how it starts

    How do I do that?


  2. MichaelH
    Posted 4 years ago #

    $url = 'http://mydomain.com';
    if (strpos($url, '://www.') == false) {
    $url = str_replace('://', '://www.',$url);
    echo '$url is ' . $url;

    But here's more where that came from:

Topic Closed

This topic has been closed to new replies.

About this Topic