Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert php array to utf8?

Tags:

I have an array:

require_once ('config.php');
require_once ('php/Db.class.php');
require_once ('php/Top.class.php');

echo "db";

$db = new Db(DB_CUSTOM);
$db->connect();

$res = $db->getResult("select first 1 * from reklamacje");

print_r($res);

I want to convert it from windows-1250 to utf-8, because I have chars like �

Best.

like image 694
user2369594 Avatar asked May 22 '13 09:05

user2369594


People also ask

How to encode string to utf-8 in PHP?

PHP | utf8_encode() Function The utf8_encode() function is an inbuilt function in PHP which is used to encode an ISO-8859-1 string to UTF-8. Unicode has been developed to describe all possible characters of all languages and includes a lot of symbols with one unique number for each symbol/character.

What is utf8 PHP?

Definition and Usage. The utf8_encode() function encodes an ISO-8859-1 string to UTF-8. Unicode is a universal standard, and has been developed to describe all possible characters of all languages plus a lot of symbols with one unique number for each character/symbol.

How to convert array PHP in string?

In this article, we are using two methods to convert array to string. Method 1: Using implode() function: The implode() method is an inbuilt function in PHP and is used to join the elements of an array. The implode() method is an alias for PHP | join() function and works exactly same as that of join() function.

What UTF-8 means?

UTF-8 (UCS Transformation Format 8) is the World Wide Web's most common character encoding. Each character is represented by one to four bytes. UTF-8 is backward-compatible with ASCII and can represent any standard Unicode character.


1 Answers

$utfEncodedArray = array_map("utf8_encode", $inputArray );

Does the job and returns a serialized array with numeric keys (not an assoc).

like image 120
Max Avatar answered Oct 01 '22 12:10

Max