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 :: wordpress curl wp remote post timeout error 
Php :: laravel query count raw 
Php :: remove public from url laravel 7 
Php :: laravel project preparation,laravel project create 
Php :: laravel load relationship including empty values 
Php :: type of var php 
Php :: Reference — What does this symbol mean in PHP? 
Php :: Writing into the database with one click laravel 
Php :: how to check if coupons are valid or not magento 2 
Php :: get all routes in laravel 
Php :: pass variable in translation larvel 
Php :: display woocommerce review using specific id 
Php :: symfony user online 
Php :: Apache/2.4.52 (Win64) OpenSSL/1.1.1m PHP/7.4.27 Server at localhost Port 80 
Php :: laravel task scheduler error 
Php :: how to get many of quensation php programming language 
Php :: all locales php 
Php :: easyadminbundle 4 $this-get(EntityRepository::class) error 
Php :: omnipay refund 
Php :: how to compare two strings ignoring accentuation in php 
Php :: pass guzzle client data to view laravel 
Php :: echo (PHP 4, PHP 5, PHP 7, PHP 8) echo — Output one or more strings 
Php :: wordpress profile queries 
Php :: php pdo memory exhausted 
Php :: get auth guard user laravel 
Php :: Unsupported type passed 
Php :: laravel collection modelKeys 
Php :: How to perform form inpot in laravel 8 and export database 
Php :: mysqldump is not recognized as an internal or external command laravel 
Php :: laravel eloquent where date today 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =