如何使用php在字符串数组中找到重复字符串?

to start of, I am not looking for array_unique(). say I have an array of strings such as:

"aok-e","aok-8","aok-c"

I want to find and remove the "aok-" from all of those values. note: I want to do this without initially knowing that value i.e. "aok-"

This seems a simple case of array_map

$items = array_map(function($a){
    return str_replace(['aok-', 'kj', 'l9'], '', $a);
}, ["aok-e","aok-8","aok-c", "kjCl9", "kjDl9"]);

Yields

['e', '8', 'c', 'C', 'D']

Adapt as needed!


Since you made an edit, here's my thought

You absolutely need something to work on at a base. If what you want is to get only the information after the "-", then it can still be done the same way. But doing so artificial intelligent search on your array is practically impossible, you're going into something very very very complex.

1) Split array using foreach loop

2) Remove or replace the string as you want using if..else condition

3) To replace string use str_replace() or substr() method