code: public static function parseComplex($complexNumber)
      {
          $workString = (string) $complexNumber;
  
          $realNumber = $imaginary = 0;
          //    Extract the suffix, if there is one
          $suffix = substr($workString, -1);
          if (!is_numeric($suffix)) {
              $workString = substr($workString, 0, -1);
          } else {
              $suffix = '';
          }
  
          //    Split the input into its Real and Imaginary components
          $leadingSign = 0;
          if (strlen($workString) > 0) {
              $leadingSign = (($workString[0] == '+') || ($workString[0] == '-')) ? 1 : 0;
          }
          $power = '';
          $realNumber = strtok($workString, '+-');
          if (strtoupper(substr($realNumber, -1)) == 'E') {
              $power = strtok('+-');
              ++$leadingSign;
          }
  
          $realNumber = substr($workString, 0, strlen($realNumber) + strlen($power) + $leadingSign);
  
          if ($suffix != '') {
              $imaginary = substr($workString, strlen($realNumber));
  
              if (($imaginary == '') && (($realNumber == '') || ($realNumber == '+') || ($realNumber == '-'))) {
                  $imaginary = $realNumber . '1';
                  $realNumber = '0';
              } elseif ($imaginary == '') {
                  $imaginary = $realNumber;
                  $realNumber = '0';
              } elseif (($imaginary == '+') || ($imaginary == '-')) {
                  $imaginary .= '1';
              }
          }
  
          return [
              'real' => $realNumber,
              'imaginary' => $imaginary,
              'suffix' => $suffix,
          ];
      }
docs: parseComplex.
  
  Parses a complex number into its real and imaginary parts, and an I or J suffix
  
  @param string $complexNumber The complex number
  
  @return string[] Indexed on "real", "imaginary" and "suffix"