So I had this dilemma the other day when I had a report that was displaying “event type”, “event name” and “event location.” Due to some wonky old data, the event name would frequently be the same as event type or event location (e.g. “Dentist Appt” as type, “Dentist Appointment” as name, and “Dentist’s Office” as location). It made sense to not show the event name if it only contained redundant information.
Unfortunately, as in the example above, “Dentist Appt” and “Dentist Appointment” are not exactly the same value, even though they have the same human meaning.
Luckily I discovered a handy little php function called similar_text(), which will compare two strings and either return the number of shared characters, or what percentage of the string is the same. So instead of saying “if event name is equal to event type, don’t show event name,” I now have something like “if event name is 85% similar to event type, don’t show it.” This seems to work pretty well, so yay! :)
Leave a Reply