0

I'm trying to split text in my web. I have this word "" and it became "?" in my web

The first i try to just print "" without any php function process and it can show "" and not became "?"

so i try to use str_split & print_r and it became "?" at all

<?php
header('content-type: text/html; charset=utf-8');
//error_reporting(E_ALL ^ ( E_NOTICE | E_WARNING ));
$letter='';
?>
<!DOCTYPE html>
<html>
<head>
    <title>memek</title>
</head>
<body>
<form method="POST">
    <input type="hidden" name="submit" id="submit" value="let">
    <textarea name='input' value="" placeholder="put text here" cols="50" rows="10"></textarea><br>
    <button type="submit" value="start">Start</button>
</form>
<?php
    function katanya($kata){
        return str_split($kata);
    }
if (isset($_POST['submit']) == 'let') {
    $letter = $_POST['input'];
    $letter = katanya($letter); 
}
?>
<textarea name="result" placeholder="result goes here"cols="50" rows="10"><?php print_r($letter); ?></textarea>
</body>
</html>

I want it not to became "?" but can show the original splitted text

edit: solved this case with this solution https://gist.github.com/ondrejmirtes/2780075?fbclid=IwAR3DDu-bn8HrowpRcGqEt02TB4iRbWWi4TLpByvR7WvSIX7rygmsbj69WJg

Amira Bedhiafi
  • 8,088
  • 6
  • 24
  • 60
  • 1
    You are dealing with a multi-byte character encoding here, so you can not use str_split, because that hacks the data apart based on byte positions only. The user comments in the manual have plenty suggestions for alternatives. – misorude Jul 29 '19 at 09:11
  • so i can't split the text using php? – Aliga Myway Jul 29 '19 at 09:14
  • Of course you can, you just have to do it properly. If you don’t know what the difference between a single- and a multi-byte character encoding is, maybe you should go read up on that a bit first of all. – misorude Jul 29 '19 at 09:18
  • sory sir :( i just want a correct code to solve this. – Aliga Myway Jul 29 '19 at 09:23
  • i dont know which keyword to searching how to solve this case – Aliga Myway Jul 29 '19 at 09:24
  • Quote from very first comment: _“The user comments in the manual have plenty suggestions for alternatives.”_ https://www.php.net/manual/en/function.str-split.php#usernotes – misorude Jul 29 '19 at 09:32
  • Possible duplicate of [Convert a String into an Array of Characters - multi-byte](https://stackoverflow.com/questions/55782088/convert-a-string-into-an-array-of-characters-multi-byte) – Dharman Jul 29 '19 at 10:33

0 Answers0