The MU forums have moved to WordPress.org

Php easy question: extract the blogname prefix (6 posts)

  1. sgrunt
    Member
    Posted 16 years ago #

    Sorry for the silly question, but i don't know a word of php.
    I want to use the blog subdomain names as Flickr tags.

    For example my blog names are something similar to:

    http://newyork.blog.com or http://london.blog.com

    i need to automatically retrieve the word "newyork" or "london", and use them as tags for each sub blog (using "substr" i presume)

    can you tell me how to extract them from the bloginfo('name') in php, and creating a new string with them?

    My goal is to show in every sub blog, flickr photos related to the sub blog title.
    Thanx!

  2. lunabyte
    Member
    Posted 16 years ago #

    Explode the http host by the dot and grab the first array value.

  3. sgrunt
    Member
    Posted 16 years ago #

    yes, but i need a way to make it dinamical, for each sub blog.

    if bloginfo('name') is london.blog.it i want to create a text string that only says "london". And then i could pass it to the flickr search.

    I only need to know how in php to create a string that is equal to bloginfo('name') - ".blog.it"

    The function to use is substr, but i am not able to write it alone...i can do that in asp but i'm really php ignorant :-)

  4. lunabyte
    Member
    Posted 16 years ago #

    Explode the http host by the dot and grab the first array value.

    Let me rephrase that according to:

    "Sorry for the silly question, but i don't know a word of php."

    Explode the http host by the dot and grab the first array value.

  5. sgrunt
    Member
    Posted 16 years ago #

    Lunabyte you are very kind, but i need sintax to grab the array value.
    How do you write the php code for obtaining a string "london" from bloginfo('name') that contains "london.blog.com", and so on for every city sub blog?
    Thanx and sorry for my bad english

  6. lunabyte
    Member
    Posted 16 years ago #

    Um, I just told you how.

    I didn't write the code for it, but I just told you exactly what to do and what to grab.

    You don't need bloginfo anything. Nothing. Zero. Zip. Nada.

About this Topic