SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    John 8:24 JREAM's Avatar
    Join Date
    Sep 2007
    Location
    Florida
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Notice: Undefined offset: 0 in C:\Active_Projects\X8\cms\core\core.php on line 115

    I don't have a clue on this, I am trying to debug and I have no idea

    PHP Code:
        for($i 1$i 12$i++) 
        {
        
    $encoded[$i] = '###block-'.$i.'###';
        
    $decoded[$i] = 'cms/data/blocks/block-'.$i.'.php';
        }

            for (
    $i=0$i count($encoded); $i++)
            {
                
    $enc $encoded[$i]; // 115
                
    ob_start();
                
                    include (
    $decoded[$i]);

                
    $tmp ob_get_contents();
                
    ob_end_clean();
                
    $file str_replace($enc$tmp$file);
            } 

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    for($i 1$i 12$i++) 
    Spot the mistake
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  3. #3
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    This saves space and execution time, especially if you might not have all of the blocks in the template. Replace the whole code block you posted with the following, if you want:
    PHP Code:
    function getBlock($match){
        
    ob_start();
            include 
    "cms/data/blocks/block-{$match[1]}.php";
        return 
    ob_get_clean();
    }
    $file preg_replace_callback('/###block-(\d*)###/i''getBlock'$file); 
    Last edited by Jake Arkinstall; Sep 14, 2008 at 12:25. Reason: fixed an error
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona


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
  •