Forums

[resolved] str_replace on bloginfo('name' (4 posts)

  1. GeorgeGecewicz
    Member
    Posted 10 months ago #

    Hey all,

    I'm trying to run this code:

    <h1><?php
       $headidslug = bloginfo('name');
       $headidslug = str_replace(" ", "", $headidslug);
       echo $headidslug;
    ?></h1>

    So that "Hey It's George" gets echoed as "heyitsgeorge", for example.

    It's not working though, any ideas or solutions? Please forgive the PHP noobness.

  2. alchymyth
    The Sweeper
    Posted 10 months ago #

    use $headidslug = get_bloginfo('name');

    and possibly add another line:

    $headidslug = strtolower($headidslug);

    http://php.net/manual/en/function.strtolower.php

  3. GeorgeGecewicz
    Member
    Posted 10 months ago #

    Thanks! This worked, I ended up using this:

    $headidslug = get_bloginfo('name');
     $headidslug = ereg_replace("[^A-Za-z]", "", $headidslug);
     $headidslug = strtolower($headidslug);
     echo $headidslug;

    this would take "Hey It's George" and make it "heyitsgeorge", and removes all numbers and stuff too :)

  4. arudd
    Member
    Posted 9 months ago #

    Sweet!
    This helped me!
    Thanks!

Reply

You must log in to post.

About this Topic