PHP array formatting method and system, electronic device and storage medium
By clearing the indentation characters or whitespace characters in the PHP array and indenting according to the code level, the display inconsistency problem in PHP array text editing is solved, and a unified format display and standardized game background configuration is achieved.
Patent Information
- Application Number
- CN202510227004.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-27
- Publication Date
- 2025-07-22
AI Technical Summary
During the PHP array text editing process, manual indentation is prone to errors, and different text editors cannot display uniformly during automatic formatting, resulting in unstandard configuration of the game background and affecting the user experience.
By obtaining the indent or whitespace characters contained in the PHP array, and then indenting according to the level of each line of code, generating a formatted PHP array.
It solves the problems of manual indentation error and inconsistent automatic formatting, ensures that PHP arrays are displayed uniformly in different editors, and improves the standardization and user experience of game background configuration.
Smart Images

Figure CN120353447A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of data processing, and particularly to a method, system, electronic device, and storage medium for formatting PHP arrays. Background Art
[0002] The game background configuration mainly consists of PHP array texts. During the editing process of PHP array texts, it is easy to have irregular indents, which affect text reading. In related technologies, when adding a new line of code, blank characters or indentation characters can be manually entered to align with the context code, but indentation errors are likely to occur; or the code can be formatted and aligned in a text editor. However, different text editors define different numbers of blank characters for indentation characters, resulting in different game background configurations being unable to be displayed in the same format, with poor user experience.
[0003] Currently, regarding the problems in related technologies where manual indentation of PHP arrays is prone to indentation errors, or automatic formatting of PHP arrays cannot be displayed in the same format by different text editors, no effective solutions have been proposed yet. Summary of the Invention
[0004] Embodiments of this application provide a method, system, electronic device, and storage medium for formatting PHP arrays to at least solve the problems in related technologies where manual indentation of PHP arrays is prone to indentation errors, or automatic formatting of PHP arrays cannot be displayed in the same format by different text editors.
[0005] In a first aspect, embodiments of this application provide a method for formatting a PHP array, and the method includes:
[0006] Obtain a PHP array to be formatted, denoted as the first PHP array;
[0007] Obtain the code in the first PHP array that contains indentation characters or blank characters, clear the indentation characters or blank characters in the first PHP array, and obtain a second PHP array;
[0008] Obtain the level to which each line of code in the second PHP array belongs, and indent each line of code according to the level to which each line of code in the second PHP array belongs, and obtain a third PHP array after formatting.
[0009] In some embodiments, obtaining the code in the first PHP array that contains indentation characters or blank characters, clearing the indentation characters or blank characters in the first PHP array, and obtaining a second PHP array includes:
[0010] Traverse each line of code in the first PHP array. When the first character of each line of code is a whitespace character, delete the first character until the first character of each line of code is not a whitespace character, and obtain a second PHP array.
[0011] In some embodiments, obtaining the level to which each line of code in the second PHP array belongs includes:
[0012] Traverse each line of code in the second PHP array. When the first preset string is matched, the levels of the next line of code and subsequent lines of code are both one more than the level of the current line of code. When the second preset string is matched, the level of the current line of code is one less than the level of the previous line of code until each line of code in the second PHP array is traversed. Among them, the line of code where the first first preset string is located is at level zero, and the line of code where the nth first preset string is located is at level n - 1.
[0013] In some embodiments, indenting each line of code according to the level to which each line of code in the second PHP array belongs includes:
[0014] Obtain an indentation table, where the indentation table is the corresponding relationship between the level to which it belongs and the number of indentation times;
[0015] Indent each line of code according to the level to which each line of code in the second PHP array belongs and the indentation table.
[0016] In a second aspect, an embodiment of the present application provides a PHP array formatting system, which includes an acquisition module, a clearing module, and an indentation module.
[0017] The acquisition module is used to acquire a PHP array to be formatted, denoted as the first PHP array;
[0018] The clearing module is used to acquire the code containing indentation characters or whitespace characters in the first PHP array, clear the indentation characters or whitespace characters in the first PHP array, and obtain a second PHP array;
[0019] The indentation module is used to acquire the level to which each line of code in the second PHP array belongs, and indent each line of code according to the level to which each line of code in the second PHP array belongs, and obtain a formatted third PHP array.
[0020] In some embodiments, acquiring the code containing indentation characters or whitespace characters in the first PHP array, clearing the indentation characters or whitespace characters in the first PHP array, and obtaining a second PHP array includes:
[0021] Traverse each line of code in the first PHP array. When the first character of each line of code is a whitespace character, delete the first character until the first character of each line of code is not a whitespace character, and obtain a second PHP array.
[0022] In some embodiments, obtaining the level to which each line of code in the second PHP array belongs includes:
[0023] Traverse each line of code in the second PHP array. When a first preset string is matched, the levels of the next line of code and subsequent code are both one more than the level of the current line of code. When a second preset string is matched, the level of the current line of code is one less than the level of the previous line of code, until each line of code in the second PHP array is traversed. Among them, the line of code where the first first preset string is located is at level zero, and the line of code where the nth first preset string is located is at level n - 1.
[0024] In some embodiments, indenting each line of code according to the level to which each line of code in the second PHP array belongs includes:
[0025] Obtain an indentation table, where the indentation table is the corresponding relationship between the level to which it belongs and the number of indentations;
[0026] Indent each line of code according to the level to which each line of code in the second PHP array belongs and the indentation table.
[0027] In a third aspect, an embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, it implements the method for formatting a PHP array as described in the first aspect above.
[0028] In a fourth aspect, an embodiment of the present application provides a storage medium, on which a computer program is stored. When the program is executed by a processor, it implements the method for formatting a PHP array as described in the first aspect above.
[0029] Compared with the related art, the method for formatting a PHP array provided by the embodiment of the present application solves the problems in the related art that it is easy to make indentation errors when manually indenting a PHP array, or different text editors cannot display it in the same format when automatically formatting a PHP array, by obtaining a PHP array to be formatted, denoted as the first PHP array, obtaining the code containing indentation characters or whitespace characters in the first PHP array, clearing the indentation characters or whitespace characters in the first PHP array to obtain a second PHP array, obtaining the level to which each line of code in the second PHP array belongs, and indenting each line of code according to the level to which each line of code in the second PHP array belongs to obtain a formatted third PHP array. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] The drawings described herein are provided to further understand the present application and form a part of the present application. The schematic embodiments of the present application and their descriptions are used to explain the present application and do not unduly limit the present application. In the drawings:
[0031] Figure 1 is a flowchart of a method for formatting a PHP array according to an embodiment of the present application;
[0032] Figure 2 is a schematic diagram of the code of the first PHP array according to an embodiment of the present application;
[0033] Figure 3 is a schematic diagram of the code of the second PHP array according to an embodiment of the present application;
[0034] Figure 4 is a schematic diagram of the code of the third PHP array according to an embodiment of the present application;
[0035] Figure 5 is a schematic diagram of the code of the fourth PHP array according to an embodiment of the present application;
[0036] Figure 6 is a schematic diagram of the code of the fifth PHP array according to an embodiment of the present application;
[0037] Figure 7 is a structural block diagram of a system for formatting a PHP array according to an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0038] In order to make the objectives, technical solutions and advantages of the present application clearer, the present application will be described and explained below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments provided in the present application without creative efforts belong to the scope of protection of the present application. In addition, it can also be understood that although the efforts made in this development process may be complex and lengthy, for those of ordinary skill in the art related to the content disclosed in the present application, some design, manufacturing or production changes based on the technical content disclosed in the present application are only conventional technical means and should not be understood as insufficient disclosure of the content of the present application.
[0039] Reference to "embodiment" in the present application means that the specific features, structures, or characteristics described in connection with the embodiment may be included in at least one embodiment of the present application. The phrase appears at various positions in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. Those of ordinary skill in the art explicitly and implicitly understand that the embodiments described in the present application may be combined with other embodiments without conflict.
[0040] Unless otherwise defined, the technical terms or scientific terms involved in the present application shall have the ordinary meaning understood by those of ordinary skill in the technical field to which the present application pertains. The words such as "a", "an", "one kind", "the" and the like involved in the present application do not indicate a limitation in quantity and may represent a singular or plural number. The terms "include", "comprise", "have" and any variations thereof involved in the present application are intended to cover non-exclusive inclusion; for example, a process, method, system, product or device that includes a series of steps or modules (units) is not limited to the listed steps or units, but may further include unlisted steps or units, or may further include other steps or units inherent to these processes, methods, products or devices. The terms "connect", "be connected", "couple" and the like involved in the present application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The "plurality" involved in the present application means greater than or equal to two. "And / or" describes the association relationship of associated objects and indicates that three relationships may exist. For example, "A and / or B" may represent: A exists alone, A and B exist simultaneously, and B exists alone. The terms "first", "second", "third" and the like involved in the present application are only used to distinguish similar objects and do not represent a specific order of the objects.
[0041] This embodiment provides a method for formatting a PHP array. Figure 1 is a flowchart of the method for formatting a PHP array according to an embodiment of the present application, as Figure 1 shown, and the method includes the following steps:
[0042] Step S101, obtain the PHP array to be formatted, denoted as the first PHP array; wherein, Hypertext Preprocessor (PHP for short) is a scripting language executed on the server side, and a PHP array is an array in PHP, and its characteristic is the type that maps values to keys. Different from other languages, the key of an array in PHP can be a string, and the value can be of any type.
[0043] When the code indentation in a PHP array is incorrect, it will cause errors in the game background configuration. For example, in a configuration, if Package 1 contains Package 2, the array level where Package 1 is located should be smaller than that of Package 2. However, if the indentation is incorrect and the array level where Package 1 is located is the same as that of Package 2, it will result in the inability to obtain the data of Package 2 when retrieving data at the array level where Package 1 is located, thus affecting the operation of the game. The method in the present invention can format a PHP array with incorrect indentation or no indentation to make the code indentation in the PHP array correct. This PHP array with incorrect indentation or no indentation is the PHP array to be formatted.
[0044] Step S102: Obtain the code containing indentation characters or whitespace characters in the first PHP array, and clear the indentation characters or whitespace characters in the first PHP array to obtain a second PHP array. Different editors define different numbers of whitespace characters for indentation characters. Generally, one indentation character corresponds to four whitespace characters. Figure 2 It is a schematic diagram of the code of the first PHP array according to an embodiment of the present application, as Figure 2 shown. This PHP array has a total of 6 lines of code. Among them, the second to fifth lines of code contain indentation characters or whitespace characters. Figure 3 It is a schematic diagram of the code of the second PHP array according to an embodiment of the present application, as Figure 3 shown. After clearing the indentation characters or whitespace characters in the second to fifth lines of code, all the code is written flush with the left margin.
[0045] Step S103: Obtain the level to which each line of code in the second PHP array belongs, and indent each line of code according to the level to which each line of code in the second PHP array belongs to obtain a third PHP array after formatting. In this embodiment, the level to which each line of code belongs can be obtained according to the writing rules of the PHP array, and each line of code is indented according to the level to which each line of code belongs.
[0046] Exemplarily, in a PHP array, when the characters of a line of code only contain the character "array(", it is the start of an array; when the characters of a line of code only contain ")", it is the end of an array. The first "array(" and the last ")" belong to the same level. By analogy, the nth "array(" and the nth ")" from the end belong to the same level. The level of the content within the array is the level number of "array(" and ")" plus one. Figure 4 It is a schematic diagram of the code of the third PHP array according to an embodiment of the present application, as Figure 4As shown, when the initial level is 0, the first line of code "array(" and the sixth line of code ")" are at level 0. The levels of the second line of code "key = value" and the third line of code "array(" are one more than the level number of the first line of code "array(" and the sixth line of code ")", so they are both at level 1. The fifth line of code ")" and the third line of code "array(" are at the same level, so it is at level 1. The fourth line of code "key = value" is one more than the level number of the third line of code "array(" and the fifth line of code ")", so it is at level 2. After obtaining the level of each line of code in the second PHP array, insert the indentation character corresponding to the level before each line of characters. For example, insert 0 indentation characters for level 0 and 1 indentation character for level 1. Finally, obtain the formatted third PHP array.
[0047] Through steps S101 to S103, compared with the related art where it is easy to make indentation errors when manually indenting a PHP array or different text editors cannot display it in the same format when automatically formatting a PHP array, in this embodiment, by obtaining the PHP array to be formatted, denoted as the first PHP array, obtaining the code in the first PHP array that contains indentation characters or whitespace characters, clearing the indentation characters or whitespace characters in the first PHP array to obtain the second PHP array, obtaining the level of each line of code in the second PHP array, and indenting each line of code according to the level of each line of code in the second PHP array to obtain the formatted third PHP array, the problem in the related art of easy indentation errors when manually indenting a PHP array or different text editors not being able to display it in the same format when automatically formatting a PHP array is solved.
[0048] Optionally, the user sends the PHP array to be formatted to the server through the browser client. After the server formats the PHP array to be formatted using the formatting method in the present invention to obtain the formatted third PHP array, it then sends the third PHP array back to the browser client. Compared with the related art where it is necessary to copy the PHP array text to some text editors or specific web pages for formatting, with cumbersome operation steps, in this embodiment, it only needs to be operated on the web page where the PHP array text is located to be formatted, without the need to rely on other additional tools, with simple operation and improved work efficiency.
[0049] In some of these embodiments, obtaining the code in the first PHP array that contains indentation characters or whitespace characters and clearing the indentation characters or whitespace characters in the first PHP array to obtain the second PHP array includes:
[0050] Traverse each line of code in the first PHP array. When the first character of each line of code is a whitespace character, delete the first character until the first character of each line of code is no longer a whitespace character, and obtain the second PHP array. In this embodiment, it is possible to determine whether the first character of each line of code is a whitespace character through a regular expression. If so, delete it until the first character of each line of code is no longer a whitespace character, that is, clear the indentation characters or whitespace characters in the first PHP array.
[0051] In some of these embodiments, obtaining the level to which each line of code in the second PHP array belongs includes: traversing each line of code in the second PHP array. In the case of matching the first preset string, the levels of the next line of code and subsequent code are both one more than the level of the current line of code. In the case of matching the second preset string, the levels of the current line of code and subsequent code are one less than the level of the previous line of code, until each line of code in the second PHP array has been traversed. Among them, the line of code where the first first preset string is located is at level zero, and the line of code where the nth first preset string is located is at level n - 1.
[0052] In this embodiment, since the PHP array format starts with "array(" and ends with ")", therefore, the first preset string is "array(", and the second preset string is ")". Figure 5 It is a schematic diagram of the code of the fourth PHP array according to an embodiment of the present application, as Figure 5 shown. The first first preset string "array(" is matched in the code of line 1. The code of line 1 is recorded as level zero. Then, the levels of the code of line 2 and line 3 are one more than the level of the code of line 1, that is, the code of line 2 and line 3 are at level 1. The second first preset string "array(" is matched in the code of line 4. The code of line 4 is recorded as level 1. The level of the code of line 5 is one more than the level of the code of line 4, that is, the code of line 5 is at level 2. The second preset string ")" is matched in the code of line 6. Then, the level of the code of line 6 is one less than the level of the code of line 5, that is, the code of line 6 is at level 1. The second preset string ")" is matched in the code of line 7. Then, the level of the code of line 7 is one less than the level of the code of line 6, that is, the code of line 7 is at level 0. Finally, each line of code in the second PHP array has been traversed, and the levels to which each line of code in the second PHP array belongs are obtained.
[0053] In some of these embodiments, indenting each line of code according to the level to which each line of code in the second PHP array belongs includes the following steps:
[0054] Step S201, obtain an indentation table, where the indentation table is the corresponding relationship between the belonging level and the indentation times; the corresponding relationship between the belonging level and the indentation times is recorded on the indentation table. When the level is 0, there is no indentation. When the level is 1, there is 1 indentation, and so on. When the level is n, there are n indentations. The user can modify and update the indentation table and customize how many blank characters one indentation character corresponds to.
[0055] Step S202, indent each line of code according to the level to which each line of code in the second PHP array belongs and the indentation table. Figure 6 It is a schematic diagram of the code of the fifth PHP array according to the embodiment of the present application. As Figure 6 shown, after obtaining the level to which each line of code in the second PHP array belongs and the indentation table, each line of code can be indented according to the corresponding relationship between the belonging level and the indentation times in the indentation table.
[0056] It should be noted that the steps shown in the above process or the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. And although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here.
[0057] This embodiment also provides a PHP array formatting system, which is used to implement the above embodiments and preferred implementation manners, and those that have been described will not be repeated. As used below, terms such as "module", "unit", "sub-unit", etc. can be a combination of software and / or hardware that can implement a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware is also possible and contemplated.
[0058] Figure 7 It is a structural block diagram of the PHP array formatting system according to the embodiment of the present application. As Figure 7 shown, the system includes an acquisition module 71, a clearing module 72, and an indentation module 73. The acquisition module 71 is used to acquire a PHP array to be formatted, denoted as the first PHP array. The clearing module 72 is used to acquire the code containing indentation characters or blank characters in the first PHP array, clear the indentation characters or blank characters in the first PHP array, and obtain the second PHP array. The indentation module 73 is used to acquire the level to which each line of code in the second PHP array belongs, and indent each line of code according to the level to which each line of code in the second PHP array belongs, and obtain the formatted third PHP array. In the related art, when manually indenting a PHP array, it is easy to make indentation errors, or when automatically formatting a PHP array, there is a problem that different text editors cannot display it in the same format.
[0059] It should be noted that each of the above modules can be a functional module or a program module, and can be implemented either by software or by hardware. For the modules implemented by hardware, each of the above modules can be located in the same processor; or each of the above modules can also be located in different processors in any combined form.
[0060] This embodiment also provides an electronic device, including a memory and a processor. A computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0061] Optionally, the above electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the above processor, and the input / output device is connected to the above processor.
[0062] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementation manners, and will not be elaborated herein.
[0063] In addition, in combination with the PHP array formatting method in the above embodiments, an embodiment of the present application can be implemented by providing a storage medium. A computer program is stored on the storage medium; when the computer program is executed by a processor, any one of the PHP array formatting methods in the above embodiments is implemented.
[0064] In one embodiment, a computer device is provided. The computer device can be a terminal. The computer device includes a processor, a memory, a network interface, a display screen, and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a PHP array formatting method is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, a trackball, or a touchpad provided on the housing of the computer device, or an external keyboard, touchpad, or mouse, etc.
[0065] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. This computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, storage, database, or other medium used in the embodiments provided in the present application can include non-volatile and / or volatile memories. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and Rambus dynamic RAM (RDRAM), etc.
[0066] Those skilled in the art should understand that the technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope described in this specification.
[0067] The above embodiments merely represent several implementation manners of the present application. The description is relatively specific and detailed, but it should not be construed as a limitation on the scope of the invention patent. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application should be subject to the appended claims.
Claims
1. A method for formatting PHP arrays, characterized in that, The method includes: Obtaining a PHP array to be formatted, denoted as the first PHP array; Obtaining the code containing indentation characters or whitespace characters in the first PHP array, and clearing the indentation characters or whitespace characters in the first PHP array to obtain a second PHP array; Obtaining the level to which each line of code in the second PHP array belongs, and indenting each line of code according to the level to which each line of code in the second PHP array belongs to obtain a formatted third PHP array.
2. The method according to claim 1, wherein Obtaining the code containing indentation characters or whitespace characters in the first PHP array, and clearing the indentation characters or whitespace characters in the first PHP array to obtain a second PHP array includes: Traversing each line of code in the first PHP array. When the first character of each line of code is a whitespace character, delete the first character until the first character of each line of code is not a whitespace character, to obtain a second PHP array.
3. The method according to claim 1, characterized in that, Obtaining the level to which each line of code in the second PHP array belongs includes: Traversing each line of code in the second PHP array. In the case of matching a first preset string, the levels to which the next line of code and subsequent lines of code belong are both one more than the level to which the current line of code belongs. In the case of matching a second preset string, the level to which the current line of code belongs is one less than the level to which the previous line of code belongs, until each line of code in the second PHP array has been traversed. Among them, the line of code where the first first preset string is located is at level zero, and the line of code where the nth first preset string is located is at level n - 1.
4. The method according to claim 1, characterized in that, Indenting each line of code according to the level to which each line of code in the second PHP array belongs includes: Obtaining an indentation table, where the indentation table is the correspondence between the level to which it belongs and the number of indentations; Indenting each line of code according to the level to which each line of code in the second PHP array belongs and the indentation table.
5. A PHP array formatting system, characterized in that, The system includes an acquisition module, a clearing module, and an indentation module. The acquisition module is used to obtain a PHP array to be formatted, denoted as the first PHP array; The clearing module is used to obtain the code containing indentation characters or whitespace characters in the first PHP array, and clear the indentation characters or whitespace characters in the first PHP array to obtain a second PHP array; The indentation module is used to obtain the level to which each line of code in the second PHP array belongs, and indent each line of code according to the level to which each line of code in the second PHP array belongs to obtain a formatted third PHP array.
6. The system according to claim 5, wherein Obtaining the code containing indentation characters or whitespace characters in the first PHP array, and clearing the indentation characters or whitespace characters in the first PHP array to obtain a second PHP array includes: Traversing each line of code in the first PHP array. When the first character of each line of code is a whitespace character, delete the first character until the first character of each line of code is not a whitespace character, to obtain a second PHP array.
7. The system according to claim 5, wherein Obtaining the level to which each line of code in the second PHP array belongs includes: Traverse each line of code in the second PHP array. When the first preset string is matched, the levels of the code in the next line and subsequent lines are incremented by one compared to the level of the current line of code. When the second preset string is matched, the level of the current line of code is decremented by one compared to the level of the previous line of code, until each line of code in the second PHP array has been traversed. Among them, the line of code where the first first preset string is located is at level zero, and the line of code where the nth first preset string is located is at level n-1.
8. The system according to claim 5, wherein Indenting each line of code according to the level of each line of code in the second PHP array includes: Obtain an indentation table, where the indentation table is the correspondence between the level and the number of indentations; Indent each line of code according to the level of each line of code in the second PHP array and the indentation table.
9. An electronic device, comprising a memory and a processor, characterized in that, A computer program is stored in the memory, and the processor is configured to run the computer program to execute the PHP array formatting method according to any one of claims 1 to 4.
10. A storage medium, characterized in that, A computer program is stored in the storage medium, where the computer program is configured to execute the PHP array formatting method according to any one of claims 1 to 4 when running.