<?php
function startsWith($haystack, $needle) {
        // search backwards starting from haystack length characters from the end
        return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== FALSE;
    }
function endsWith($haystack, $needle) {
        // search forward starting from end minus needle length characters
        return $needle === "" || (($temp = strlen($haystack) - strlen($needle)) >= 0 && strpos($haystack, $needle, $temp) !== FALSE);
    }

if (startsWith("1,2", "1,") || endsWith("1,2", ",3"))
 echo "True1". "\n";
if (startsWith("31,2", "1,") || endsWith("31,2",",3"))
 echo "True2". "\n";
if (startsWith("4,3", "1,") || endsWith("4,3",",3"))
 echo "True3" . "\n";
