SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2005
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem with foreach() and substr/stristr

    Can anyone tell me why this code:
    PHP Code:
    <?php
    foreach ($theme_ini as $name => $values
    {
        switch (
    substr($name0stristr($name'-') - 1))
        {
        }
    }
    ?>
    with $name being 'stylesheet-1', 'stylesheet-2' etc results in substr($name, 0, stristr($name, '-') - 1) being 'stylesheet' the first time round, then 'styleshee', then 'styleshe' and so on? It's bloody annoying!

  2. #2
    SitePoint Enthusiast
    Join Date
    Jul 2007
    Location
    Indonesia - Bali
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it will be better if you post your array data
    i cannot understand if not see your content of your array

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2005
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nevermind, I was just using the wrong function - stristr instead of strpos

  4. #4
    SitePoint Enthusiast
    Join Date
    Jul 2007
    Location
    Indonesia - Bali
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    wooooooo......


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •