$filename = "file.txt"; if (Piwik\Common::stringEndsWith($filename, ".txt")) { echo "This file is a text file."; } else { echo "This file is not a text file."; }
$filename = "file.txt"; if (Piwik\Common::stringEndsWith($filename, ".txt")) { $trimmed = substr($filename, 0, -4); // removes the last 4 characters of the string echo "The filename without extension: $trimmed"; } else { echo "This file does not have a .txt extension."; }It's important to note that stringEndsWith is part of the Common package library in Piwik, which contains a set of commonly used functions that can be reused across different areas of the platform.