Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php function to print array value by key

function kPrint($key,$obj){    
    return (gettype($obj)=="array"?(array_key_exists($key,$obj)?$obj[$key]:("<font color='red'>NA</font>")):(gettype($obj)=="object"?(property_exists($obj,$key)?$obj->$key:("<font color='red'>NA</font>")):("<font color='red'><font color='green'>:::Exception Start:::</font><br>Invalid Object/Array Passed at kPrint() Function!!<br> At : Variable => ".print_r($obj)."<br>Key => ".$key."<br> At File: <font color='blue'>".debug_backtrace()[0]['file']."</font><br> At Line : ".debug_backtrace()[0]['line']."<br><font color='green'>:::Exception End:::</font></font>")));
}

//call this function in echo and pass parameters like key and array/object
Comment

PREVIOUS NEXT
Code Example
Php :: what returns livewire mount 
Php :: ErrorException Undefined index(laravel 7 array helpers) 
Php :: error import php 
Php :: Laravel Http client retry request if fail 
Php :: php xpath get all tags under a tag 
Php :: How to get only content-length with CURL PHP? 
Php :: wordpress register_post_type capability gutenberg 
Php :: Get and access to the order data properties (in an array of values): 
Php :: Laravel : Pass dynamic variables to routes 
Php :: laravel - How to concatenate URL and retrieve images from database in json format 
Php :: php base64 encode utf8 
Php :: Lavavel nova toggle 
Php :: PHP OOP - Static Methods 
Php :: expresions 
Php :: php delete acc 
Php :: add code return block phpstorm 
Php :: registration welcome email laravel 
Php :: dql if or ifnull 
Php :: php variables as keys in arrays 
Php :: prestashop get product id 
Php :: woocommerce check if shop page 
Php :: stripslash 
Php :: regex sl nic validation laravel 
Php :: unexpected end of file php 
Php :: facade pattern php 
Java :: recycler view dependency 
Java :: how to play sounds on java 
Java :: java log base 2 
Java :: install java apt 
Java :: java random boolean 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =