PHP string processing (letter extraction) is like this. The student ID of the school is a mix of numbers and letters. The letter represents the system name.
For example, in 6SC14032S, SC is the Department of Science. what should I do if I want to extract the student IDs from the same department into an array. (The student ID is in the MYSQL database .)
Reply to discussion (solution)
First, extract the data from the database, then use regular expression matching to retrieve the middle letter, and press find letter component array.
What do you mean by removing the current student ID from the letter? Keep the number and store it in the array?
If this parameter is not excluded, find a letter. the student ID of the corresponding letter has an array.
What does the first 6 mean?
6 indicates that doctoral 5 is a graduate student.
Use substr to get by bit and then put it into an array.
$ N = '6sc14032s'; $ arr = array (); $ arr [] = substr ($ n, 0, 1); $ arr [] = substr ($ n, 1, 2 ); $ arr [] = substr ($ n, 3, 5); $ arr [] = substr ($ n, 8, 1); print_r ($ arr );
Select * from table where id like '% SC %'
First extract the data from the database, then use regular expression matching to retrieve the middle letter, and then group the data by letter into an array.