SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Exploding

Hybrid View

  1. #1
    SitePoint Enthusiast DamienGiles's Avatar
    Join Date
    Mar 2005
    Posts
    85
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exploding

    Hi,

    You know when you can't find a simple solution without creating lines of code?

    Well this is it - can someone suggest a simple, clean way of doing it.

    PHP Code:
    $Config = array(
      
    'system' => array(
        
    'memory' => array(
          
    'maxmemory' => 16
        
    )
      )
    );

    $Query "system.memory.maxmemory"
    I want to find if $Query is going in $Config?
    Keep life simple... don't put your head through plexiglass.

  2. #2
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    foreach ( explode'.'$query ) as $test ) {
        if ( !isset( 
    $tmp_config ) ) $tmp_config =& $global_config;
        if ( !isset( 
    $tmp_config$test ] ) ) {
            
    $reached false; break;
        }

        
    $tmp_config =& $tmp_config$test ];
        
    $reached true;
    }

    if ( 
    $reached === true ) echo 'For config?'
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.



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
  •