Y
Y
yooooooman2021-07-24 06:34:22
PHP
yooooooman, 2021-07-24 06:34:22

Why different length of string in array?

I do import/export. When importing, I want to compare the array from the file with the array from the database in order to find discrepancies and then go through only the id, the data of which diverges in some way. But when compared, it shows discrepancies due to the length of the strings, although the encoding is the same and the data is also the same.

First, I create an object from an array using fputcsv , and then I write the object to a csv file using fwrite. If you display arrays from the recorded file and from the database via var_dump, it shows the differences in the length of the string strings.

Example
Array from base

array(4) {
  ["description"]=>
  string(897) "Текст..."
}

Array from the written file
array(4) {
    ["description"]=>
    string(895) "Текст..."
  }

The text is the same, the encoding too. Why is this happening and how to bring it to a unified one?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2021-07-24
@yooooooman

Reading manuals, learning materiel...
60fb8ddb15103133504433.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question