I dont understand that much of arrays. But here I have to find the item of the array the substring H_____ and compare with other items and if equal merge. I found examples of removing duplicates and finding exactly same item, but this is not the case.
Tested and it is sound (as long as the extra spaces aren’t correct before the numbers, otherwise its an index of 4 in the first foreach loop). Wow, I would have never in my wildest dreams have guessed to do it that way. Talk about a learning experience! Thanks StarLion!
It’s a bit of a weak solution (relies on string positioning, two foreach loops to do one sort), and a bit incomplete (should create an empty array in $final[$shards[3]] if $final[$shards[3]] is not set first), but it was the only way i could come up with that imploded the + symbols in. (Without the +, it would be as simple as $final[$shards[3]] .= $string with no second loop)
EDIT: I suppose i could do it as string manipulation with a isset check instead… mumbles, pokes at it a bit more
Hi that is awesome! And works for the example I gave, however unfortunately not always I have the same number of spaces, characters before and after the H______
It could be something like this:
So lesson learned: Always give as much detail as you can, or else your answer will be incomplete.
I’ll give you the hints this time though, rather than the code.
Hint #1: You only need to completely change one of the lines above.(Though error-checking may add an additional line, if desired). The other line only requires variable replacement.
Hint #2: preg_match to find the key. Your pattern for the regex would be “#H\d+#”.