diff --git a/Build/Scripts/runTests.sh b/Build/Scripts/runTests.sh
index da27d63c84ebbf34ee6d7be56b0c1ca4b0c0645a..2b3fffc7eb6e4983e43b65e1262c82ad25f24a0f 100755
--- a/Build/Scripts/runTests.sh
+++ b/Build/Scripts/runTests.sh
@@ -159,6 +159,26 @@ cleanRenderedDocumentationFiles() {
     echo "done"
 }
 
+getPhpImageVersion() {
+    case ${1} in
+        7.4)
+            echo -n "2.4"
+            ;;
+        8.0)
+            echo -n "2.4"
+            ;;
+        8.1)
+            echo -n "2.7"
+            ;;
+        8.2)
+            echo -n "1.6"
+            ;;
+        8.3)
+            echo -n "1.7"
+            ;;
+    esac
+}
+
 loadHelp() {
     # Load help text into $HELP
     read -r -d '' HELP <<EOF
@@ -393,13 +413,6 @@ SUFFIX=$(echo $RANDOM)
 NETWORK="typo3-core-${SUFFIX}"
 CI_PARAMS=""
 CONTAINER_HOST="host.docker.internal"
-declare -A PHP_IMAGE_VERSIONS=(
-    ["7.4"]="2.4"
-    ["8.0"]="2.4"
-    ["8.1"]="2.7"
-    ["8.2"]="1.6"
-    ["8.3"]="1.7"
-)
 
 # Option parsing updates above default vars
 # Reset in case getopts has been used previously in the shell
@@ -438,7 +451,7 @@ while getopts ":a:b:s:c:d:i:p:e:xy:o:nhug" OPT; do
             ;;
         p)
             PHP_VERSION=${OPTARG}
-            if [[ -z "${PHP_IMAGE_VERSIONS[${PHP_VERSION}]:-}" ]]; then
+            if ! [[ ${PHP_VERSION} =~ ^(7.4|8.0|8.1|8.2|8.3)$ ]]; then
                 INVALID_OPTIONS+=("${OPTARG}")
             fi
             ;;
@@ -508,7 +521,7 @@ if ! type ${CONTAINER_BIN} >/dev/null 2>&1; then
     exit 1
 fi
 
-IMAGE_PHP="ghcr.io/typo3/core-testing-$(echo "php${PHP_VERSION}" | sed -e 's/\.//'):${PHP_IMAGE_VERSIONS[$PHP_VERSION]}"
+IMAGE_PHP="ghcr.io/typo3/core-testing-$(echo "php${PHP_VERSION}" | sed -e 's/\.//'):$(getPhpImageVersion $PHP_VERSION)"
 IMAGE_NODEJS="ghcr.io/typo3/core-testing-js:1.3"
 IMAGE_NODEJS_CHROME="ghcr.io/typo3/core-testing-js-chrome:1.3"
 IMAGE_ALPINE="docker.io/alpine:3.8"