Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts

Sunday, 28 June 2020

How to print subdirectories in PHP program?

Here is the php code to print the subdirectories

PHP CODE:

<?php

$dirs = array_filter(glob('*'), 'is_dir');
print_r( $dirs);

Output:

Array ( [0] => follow us [1] => htetcomp )

Wednesday, 25 December 2019

json encode chinese character php

json encode chinese character php

-------json_encode() in PHP returns Chinese characters in escaped-------

Many time you were not able to create php json_encode from special characters which generate the  null. I have a code by which you can create a valid json in php 


//****************start encodeing***********/
$data  = array(
array('Sr No'=> 1,'name' => "删除一个连续数组值的方式产生的非连续数组"),
array('Sr No'=> 2,'name' => "删除一个连续数组值的方式产生的非连续数组"),
array('Sr No'=> 3,'name' => "删除一个连续数组值的方式产生的非连续数组")
);


foreach ($data as $key => $value) {
$data[$key]['name'] = mb_convert_encoding($value['name'], "UTF-8", "UTF-8");
}
echo json_encode($data);

///*************end ********************//

using  mb_convert_encoding($string, "UTF-8", "UTF-8");
function you can easily create a valid jSon 

// ************output is given below ***********//
php json_encode special characters null solved

Method 2:  Change collation to utf8mb4_unicode_ci In mysql DB of your column.

Thanks for sharing your time. I believe that you issue has been resolved Please Give a comment to support my efforts. Thanks