GithubHelp home page GithubHelp logo

Comments (5)

yayabla avatar yayabla commented on May 17, 2024 5

Change your code to this.

`private static function _object(&$data, $name)
{
?>

  • 		<div <?php if ((is_object($data) && count(get_object_vars($data)) > 0) || count($data) > 0) {?> onClick="krumo.toggle(this);"<?php } ?>
    			class="krumo-element<?php echo (is_object($data) && count(get_object_vars($data)) > 0) || count($data) > 0 ? ' krumo-expand' : '';?>" >
    
    				<a class="krumo-name"><?php echo $name;?></a>
    				(<em class="krumo-type">Object</em>)
    				<strong class="krumo-class"><?php echo get_class($data);?></strong>
    		</div>
    
    		<?php if ((is_object($data) && count(get_object_vars($data)) > 0) || count($data))
    		{
    			self::_vars($data);
    		} ?>
    	</li>
    	<?php
    }`
    
  • from krumo.

    Kashiffrq avatar Kashiffrq commented on May 17, 2024 2
    if ( is_array( $data) ) {
    		if ( $data > count( $data) ) // if the requested data doesn't exist
    			$data = count( $data); // give them the highest numbered data that DOES exist
    	} else { 	
    		$data= 0;
    	}
    

    from krumo.

    kktsvetkov avatar kktsvetkov commented on May 17, 2024

    Casting $data to an array causes more bugs. Ideas?

    This is used to render objects, so it should not be converted to array. The suggestion from @yayabla to use get_object_vars($data) is the best approach

    from krumo.

    kktsvetkov avatar kktsvetkov commented on May 17, 2024

    Issue is fixed in 0.4.1

    from krumo.

    ZakiBelhadj avatar ZakiBelhadj commented on May 17, 2024

    Try this Solution:

    if ( count( $_posts )) {
    ....
    }

    Add "is_array($_posts) &&" to become:

    if (is_array($_posts) && count($_posts) ) {
    ....
    }

    from krumo.

    Related Issues (10)

    Recommend Projects

    • React photo React

      A declarative, efficient, and flexible JavaScript library for building user interfaces.

    • Vue.js photo Vue.js

      🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

    • Typescript photo Typescript

      TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

    • TensorFlow photo TensorFlow

      An Open Source Machine Learning Framework for Everyone

    • Django photo Django

      The Web framework for perfectionists with deadlines.

    • D3 photo D3

      Bring data to life with SVG, Canvas and HTML. 📊📈🎉

    Recommend Topics

    • javascript

      JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

    • web

      Some thing interesting about web. New door for the world.

    • server

      A server is a program made to process requests and deliver data to clients.

    • Machine learning

      Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

    • Game

      Some thing interesting about game, make everyone happy.

    Recommend Org

    • Facebook photo Facebook

      We are working to build community through open source technology. NB: members must have two-factor auth.

    • Microsoft photo Microsoft

      Open source projects and samples from Microsoft.

    • Google photo Google

      Google ❤️ Open Source for everyone.

    • D3 photo D3

      Data-Driven Documents codes.