PHP character loop string truncation, PHP traversal string character

Updated on technology 2024-08-07
6 answers
  1. Anonymous users2024-02-15

    Yours,It's the biggest support for me.,If you don't understand, you can continue to ask pkaust8 effect for a loop output:

    arr = explode("#####",$str);

    foreach($arr as $a){

    echo $a."

    Effect 2: Get the first path:

    arr = explode("#####",$str);

    echo $arr [0]";

  2. Anonymous users2024-02-14

    ** on the 1st floor is a bit of a problem Intercepting Chinese will have problems For example, it is exactly 9 letters and 1 Chinese character, if you intercept 10 digits, there will be garbled characters, so when intercepting strings containing Chinese, you should use mb substr instead of substr

    for($i=0;$istring=mb_substr($str,$i,10);

    echo $string."

    Seek satisfaction.

  3. Anonymous users2024-02-13

    There's a bit of a problem upstairs. Also consider the format of the string. And whether the string contains Chinese...

  4. Anonymous users2024-02-12

    Intercept them one by one and put them into an array.

  5. Anonymous users2024-02-11

    php Chinese.

    Causes and solutions of garbled characters.

    Reason: The encoding type of the page language itself is not suitable, at this time, the Chinese you write directly in the script must be garbled, not to mention the database;

    Workaround: Select'

    utf8 or'gb2312', so that the customer's browser automatically selects and appears correctly in Chinese. Note:'utf8'or'gb2312'can display Chinese correctly.

    2.The encoding type in the database mysql is incorrect.

    Solution: When creating a database, use mysql

    Character set selection'utf8',mysql

    Connect to proofread UTF8 General CI, so that the created database is used to store Chinese must have no problem, otherwise, your Chinese is garbled in MySQL first, let alone expect it to display correctly in PHP pages for you.

    3.It is related to the usual scripting environment. For example, some of the content is written by yourself in Word, some is written in Notepad, and some is written in EditPlus, UltraPlus, etc.

    Texter. Sometimes I write Chinese directly in dw, so it's strange that there is no garbled characters.

    Solution: Try to use the same device. If you want to copy the existing content, it is recommended to use the encoding conversion function in UltraPlus to convert it to UTF8 or GB2312.

    It doesn't matter what type you convert to, it's your PHP

    web applications.

    The coding in should be consistent.

    4.Programmatic access.

    MySQL, we recommend that you add a line **:MySQL query(.)."set

    namesgbk'");

    Here's how to fix it.

    I didn't understand you.

    Paste on the program.

    So give you some ways to solve the problem of garbled characters.

    Hope it helps.

  6. Anonymous users2024-02-10

    Causes and solutions of php Chinese garbled characters.

    Reason: The encoding type of the page language itself is not suitable, at this time, the Chinese you write directly in the script must be garbled, not to mention the database;

    Workaround: Select'utf8'or'gb2312', so that the customer's browser automatically selects and appears correctly in Chinese. Note:'utf8'or'gb2312'can display Chinese correctly.

    2.The encoding type in the database mysql is incorrect.

    Solution: When creating a database, use mysql

    Character set selection'utf8',mysql

    Connect to proofread UTF8 General CI, so that the created database is used to store Chinese must have no problem, otherwise, your Chinese is garbled in MySQL first, let alone expect it to display correctly in PHP pages for you.

    3.It is related to the usual scripting environment. For example, some content is written in Word, some is written in Notepad, and some is written in texters such as EditPlus and UltraPlus.

    Sometimes I write Chinese directly in dw, so it's strange that there is no garbled characters.

    Solution: Try to use the same device. If you want to copy the existing content, it is recommended to use the encoding conversion function in UltraPlus to convert it to UTF8 or GB2312.

    It doesn't matter what type you convert to, it's your PHP

    The coding in the web application should be consistent.

    4.Programmatic access.

    MySQL, we recommend that you add a line **:MySQL query(.)."set

    names'gbk'")

    Here's how to fix it.

    I didn't understand the program you posted.

    So give you some ways to solve the problem of garbled characters.

    Hope it helps.

Related questions
11 answers2024-08-07

Hello landlord.

It's a bit winding with recursion, but you can actually use a loop to reverse the string. >>>More

12 answers2024-08-07

Two methods:

1: fileext=right("images/", 3) two: filename="images/" >>>More

7 answers2024-08-07

db->get_results('select * from '.tb_prefix.'product where categoryid=10'); >>>More

8 answers2024-08-07

It seems to be BAT, and it is difficult to achieve it with the following methods. >>>More

11 answers2024-08-07

First of all, it is necessary to understand what a binary tree is (and I guess the subject also understands). >>>More