input: Write a function named `longestCommonSubstring` that takes two strings `string1` and `string2` as inputs and returns the longest common substring between the two strings. The function should use a dynamic programming approach to find the longest common substring.
  
  assert longestCommonSubstring("abcdef", "zcdxyz")=="cd"
  assert longestCommonSubstring("hello", "world")==""
  assert longestCommonSubstring("dynamic", "programming")=="ming"
  assert longestCommonSubstring("python", "typhon")=="ython"
  assert longestCommonSubstring("", "")==""
output: def longestCommonSubstring(string1, string2):
      m, n = len(string1), len(string2)
      dp = [[0] * (n + 1) for _ in range(m + 1)]
      max_len = 0
      end_index = 0
      
      for i in range(1, m + 1):
          for j in range(1, n + 1):
              if string1[i - 1] == string2[j - 1]:
                  dp[i][j] = dp[i - 1][j - 1] + 1
                  if dp[i][j] > max_len:
                      max_len = dp[i][j]
                      end_index = i
      
      return string1[end_index - max_len:end_index]