How to get rid of the dots?












-1















A picture of the problem



I want to check multiple domains with my autocomplete function and it works! Only it detects a dot (as you can see in front of the domain name) what is probably hidden somewhere inside the code and because of the dot it will be a invalid domain name. I think it`s because of this part of my code:



$arr =  explode('.', $q);


and for the extra information, here is the rest of my code:



$a = array("com", "co", "net", "nl");
$q = (isset($_REQUEST["q"]) ? $_REQUEST["q"] : null);
$arr = explode('.', $q);
$result = '';
@$domains = explode("n", $_GET['domains']);
$domains = array_map('trim', $domains);

$output = array();
foreach ($a as &$value) {
if (substr($value, 0, strlen(@$arr[1])) === @$arr[1])
{
$output= $arr[0] . "." . $value;

foreach ($output as &$domeinnaam) {
try
{
$domainCheckResults = Transip_DomainService::batchCheckAvailability($domains);
foreach($domainCheckResults as $domainCheckResult)
{
switch($domainCheckResult->status)
{
case Transip_DomainService::AVAILABILITY_INYOURACCOUNT:
$result .= htmlspecialchars($domeinnaam->domainName)
. ' ✕<br/>';
break;
case Transip_DomainService::AVAILABILITY_UNAVAILABLE:
$result .= htmlspecialchars($domeinnaam->domainName)
. ' ✕<br/>';
break;
case Transip_DomainService::AVAILABILITY_FREE:
$result .= htmlspecialchars($domeinnaam->domainName)
. ' ✓<br/>';
break;
case Transip_DomainService::AVAILABILITY_NOTFREE:
$result .= htmlspecialchars($domeinnaam->domainName)
. '❔<br/>';
break;
}
}
}
catch(SoapFault $e)
{
$result = 'Er vind een error plaats: ' . htmlspecialchars($e->getMessage());
}
}


echo $domeinnaam."<br>";
echo $result;

}}









share|improve this question



























    -1















    A picture of the problem



    I want to check multiple domains with my autocomplete function and it works! Only it detects a dot (as you can see in front of the domain name) what is probably hidden somewhere inside the code and because of the dot it will be a invalid domain name. I think it`s because of this part of my code:



    $arr =  explode('.', $q);


    and for the extra information, here is the rest of my code:



    $a = array("com", "co", "net", "nl");
    $q = (isset($_REQUEST["q"]) ? $_REQUEST["q"] : null);
    $arr = explode('.', $q);
    $result = '';
    @$domains = explode("n", $_GET['domains']);
    $domains = array_map('trim', $domains);

    $output = array();
    foreach ($a as &$value) {
    if (substr($value, 0, strlen(@$arr[1])) === @$arr[1])
    {
    $output= $arr[0] . "." . $value;

    foreach ($output as &$domeinnaam) {
    try
    {
    $domainCheckResults = Transip_DomainService::batchCheckAvailability($domains);
    foreach($domainCheckResults as $domainCheckResult)
    {
    switch($domainCheckResult->status)
    {
    case Transip_DomainService::AVAILABILITY_INYOURACCOUNT:
    $result .= htmlspecialchars($domeinnaam->domainName)
    . ' ✕<br/>';
    break;
    case Transip_DomainService::AVAILABILITY_UNAVAILABLE:
    $result .= htmlspecialchars($domeinnaam->domainName)
    . ' ✕<br/>';
    break;
    case Transip_DomainService::AVAILABILITY_FREE:
    $result .= htmlspecialchars($domeinnaam->domainName)
    . ' ✓<br/>';
    break;
    case Transip_DomainService::AVAILABILITY_NOTFREE:
    $result .= htmlspecialchars($domeinnaam->domainName)
    . '❔<br/>';
    break;
    }
    }
    }
    catch(SoapFault $e)
    {
    $result = 'Er vind een error plaats: ' . htmlspecialchars($e->getMessage());
    }
    }


    echo $domeinnaam."<br>";
    echo $result;

    }}









    share|improve this question

























      -1












      -1








      -1








      A picture of the problem



      I want to check multiple domains with my autocomplete function and it works! Only it detects a dot (as you can see in front of the domain name) what is probably hidden somewhere inside the code and because of the dot it will be a invalid domain name. I think it`s because of this part of my code:



      $arr =  explode('.', $q);


      and for the extra information, here is the rest of my code:



      $a = array("com", "co", "net", "nl");
      $q = (isset($_REQUEST["q"]) ? $_REQUEST["q"] : null);
      $arr = explode('.', $q);
      $result = '';
      @$domains = explode("n", $_GET['domains']);
      $domains = array_map('trim', $domains);

      $output = array();
      foreach ($a as &$value) {
      if (substr($value, 0, strlen(@$arr[1])) === @$arr[1])
      {
      $output= $arr[0] . "." . $value;

      foreach ($output as &$domeinnaam) {
      try
      {
      $domainCheckResults = Transip_DomainService::batchCheckAvailability($domains);
      foreach($domainCheckResults as $domainCheckResult)
      {
      switch($domainCheckResult->status)
      {
      case Transip_DomainService::AVAILABILITY_INYOURACCOUNT:
      $result .= htmlspecialchars($domeinnaam->domainName)
      . ' ✕<br/>';
      break;
      case Transip_DomainService::AVAILABILITY_UNAVAILABLE:
      $result .= htmlspecialchars($domeinnaam->domainName)
      . ' ✕<br/>';
      break;
      case Transip_DomainService::AVAILABILITY_FREE:
      $result .= htmlspecialchars($domeinnaam->domainName)
      . ' ✓<br/>';
      break;
      case Transip_DomainService::AVAILABILITY_NOTFREE:
      $result .= htmlspecialchars($domeinnaam->domainName)
      . '❔<br/>';
      break;
      }
      }
      }
      catch(SoapFault $e)
      {
      $result = 'Er vind een error plaats: ' . htmlspecialchars($e->getMessage());
      }
      }


      echo $domeinnaam."<br>";
      echo $result;

      }}









      share|improve this question














      A picture of the problem



      I want to check multiple domains with my autocomplete function and it works! Only it detects a dot (as you can see in front of the domain name) what is probably hidden somewhere inside the code and because of the dot it will be a invalid domain name. I think it`s because of this part of my code:



      $arr =  explode('.', $q);


      and for the extra information, here is the rest of my code:



      $a = array("com", "co", "net", "nl");
      $q = (isset($_REQUEST["q"]) ? $_REQUEST["q"] : null);
      $arr = explode('.', $q);
      $result = '';
      @$domains = explode("n", $_GET['domains']);
      $domains = array_map('trim', $domains);

      $output = array();
      foreach ($a as &$value) {
      if (substr($value, 0, strlen(@$arr[1])) === @$arr[1])
      {
      $output= $arr[0] . "." . $value;

      foreach ($output as &$domeinnaam) {
      try
      {
      $domainCheckResults = Transip_DomainService::batchCheckAvailability($domains);
      foreach($domainCheckResults as $domainCheckResult)
      {
      switch($domainCheckResult->status)
      {
      case Transip_DomainService::AVAILABILITY_INYOURACCOUNT:
      $result .= htmlspecialchars($domeinnaam->domainName)
      . ' ✕<br/>';
      break;
      case Transip_DomainService::AVAILABILITY_UNAVAILABLE:
      $result .= htmlspecialchars($domeinnaam->domainName)
      . ' ✕<br/>';
      break;
      case Transip_DomainService::AVAILABILITY_FREE:
      $result .= htmlspecialchars($domeinnaam->domainName)
      . ' ✓<br/>';
      break;
      case Transip_DomainService::AVAILABILITY_NOTFREE:
      $result .= htmlspecialchars($domeinnaam->domainName)
      . '❔<br/>';
      break;
      }
      }
      }
      catch(SoapFault $e)
      {
      $result = 'Er vind een error plaats: ' . htmlspecialchars($e->getMessage());
      }
      }


      echo $domeinnaam."<br>";
      echo $result;

      }}






      php explode






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 14 '18 at 12:18







      user10477251































          2 Answers
          2






          active

          oldest

          votes


















          0














          You mentioned the word 'autocomplete'. If this is sending off a request to the domain-checker API on every key-stroke, it might be picking up the dot and sending that off too.



          I'd break this down into its simplest form to eliminate any quirks that might be caused by the autocomplete - get it working with a hard-coded domain and then build on top of that. I'd also recommend removing the @ symbol to suppress errors, especially as you're troubleshooting code.






          share|improve this answer
























          • Yes but the only problem I got is the dot that's indeed getting picked up for some reason. The variables with a @ in front of it were all notice messages that didn't thwart things from happening. So I think it`s because of the explode part but I need that part to make it an sort of autocomplete function.

            – user10477251
            Nov 14 '18 at 12:50













          • I suspect that's not the only problem. You're sending $domains to the batchCheckAvailability call, so what's in the $q parameter that you're exploding? It looks like you're working on $_REQUEST["q"], but then sending $_GET['domains'] to the API. I think you're going to need to clean up and simplify before the issue becomes obvious.

            – Morris
            Nov 14 '18 at 13:17











          • $q is like the erre in the picture, so like everything before the dot.

            – user10477251
            Nov 14 '18 at 13:21



















          -1














          It surely seems like it. you're splitting an array with '.' in between them. if you want to get rid of that, just explode it with an empty string
          explode('', $q);






          share|improve this answer
























          • You cannot explode on an empty string.

            – jeroen
            Nov 14 '18 at 12:27











          • I need to explode it otherwise I couldn`t autocomplete the domain name after the dot.

            – user10477251
            Nov 14 '18 at 12:30











          • you can't explode an empty string, but you can explode a string with an empty delimiter, no?

            – Glenn van Acker
            Nov 14 '18 at 14:19











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53300077%2fhow-to-get-rid-of-the-dots%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown
























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          You mentioned the word 'autocomplete'. If this is sending off a request to the domain-checker API on every key-stroke, it might be picking up the dot and sending that off too.



          I'd break this down into its simplest form to eliminate any quirks that might be caused by the autocomplete - get it working with a hard-coded domain and then build on top of that. I'd also recommend removing the @ symbol to suppress errors, especially as you're troubleshooting code.






          share|improve this answer
























          • Yes but the only problem I got is the dot that's indeed getting picked up for some reason. The variables with a @ in front of it were all notice messages that didn't thwart things from happening. So I think it`s because of the explode part but I need that part to make it an sort of autocomplete function.

            – user10477251
            Nov 14 '18 at 12:50













          • I suspect that's not the only problem. You're sending $domains to the batchCheckAvailability call, so what's in the $q parameter that you're exploding? It looks like you're working on $_REQUEST["q"], but then sending $_GET['domains'] to the API. I think you're going to need to clean up and simplify before the issue becomes obvious.

            – Morris
            Nov 14 '18 at 13:17











          • $q is like the erre in the picture, so like everything before the dot.

            – user10477251
            Nov 14 '18 at 13:21
















          0














          You mentioned the word 'autocomplete'. If this is sending off a request to the domain-checker API on every key-stroke, it might be picking up the dot and sending that off too.



          I'd break this down into its simplest form to eliminate any quirks that might be caused by the autocomplete - get it working with a hard-coded domain and then build on top of that. I'd also recommend removing the @ symbol to suppress errors, especially as you're troubleshooting code.






          share|improve this answer
























          • Yes but the only problem I got is the dot that's indeed getting picked up for some reason. The variables with a @ in front of it were all notice messages that didn't thwart things from happening. So I think it`s because of the explode part but I need that part to make it an sort of autocomplete function.

            – user10477251
            Nov 14 '18 at 12:50













          • I suspect that's not the only problem. You're sending $domains to the batchCheckAvailability call, so what's in the $q parameter that you're exploding? It looks like you're working on $_REQUEST["q"], but then sending $_GET['domains'] to the API. I think you're going to need to clean up and simplify before the issue becomes obvious.

            – Morris
            Nov 14 '18 at 13:17











          • $q is like the erre in the picture, so like everything before the dot.

            – user10477251
            Nov 14 '18 at 13:21














          0












          0








          0







          You mentioned the word 'autocomplete'. If this is sending off a request to the domain-checker API on every key-stroke, it might be picking up the dot and sending that off too.



          I'd break this down into its simplest form to eliminate any quirks that might be caused by the autocomplete - get it working with a hard-coded domain and then build on top of that. I'd also recommend removing the @ symbol to suppress errors, especially as you're troubleshooting code.






          share|improve this answer













          You mentioned the word 'autocomplete'. If this is sending off a request to the domain-checker API on every key-stroke, it might be picking up the dot and sending that off too.



          I'd break this down into its simplest form to eliminate any quirks that might be caused by the autocomplete - get it working with a hard-coded domain and then build on top of that. I'd also recommend removing the @ symbol to suppress errors, especially as you're troubleshooting code.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 14 '18 at 12:39









          MorrisMorris

          313




          313













          • Yes but the only problem I got is the dot that's indeed getting picked up for some reason. The variables with a @ in front of it were all notice messages that didn't thwart things from happening. So I think it`s because of the explode part but I need that part to make it an sort of autocomplete function.

            – user10477251
            Nov 14 '18 at 12:50













          • I suspect that's not the only problem. You're sending $domains to the batchCheckAvailability call, so what's in the $q parameter that you're exploding? It looks like you're working on $_REQUEST["q"], but then sending $_GET['domains'] to the API. I think you're going to need to clean up and simplify before the issue becomes obvious.

            – Morris
            Nov 14 '18 at 13:17











          • $q is like the erre in the picture, so like everything before the dot.

            – user10477251
            Nov 14 '18 at 13:21



















          • Yes but the only problem I got is the dot that's indeed getting picked up for some reason. The variables with a @ in front of it were all notice messages that didn't thwart things from happening. So I think it`s because of the explode part but I need that part to make it an sort of autocomplete function.

            – user10477251
            Nov 14 '18 at 12:50













          • I suspect that's not the only problem. You're sending $domains to the batchCheckAvailability call, so what's in the $q parameter that you're exploding? It looks like you're working on $_REQUEST["q"], but then sending $_GET['domains'] to the API. I think you're going to need to clean up and simplify before the issue becomes obvious.

            – Morris
            Nov 14 '18 at 13:17











          • $q is like the erre in the picture, so like everything before the dot.

            – user10477251
            Nov 14 '18 at 13:21

















          Yes but the only problem I got is the dot that's indeed getting picked up for some reason. The variables with a @ in front of it were all notice messages that didn't thwart things from happening. So I think it`s because of the explode part but I need that part to make it an sort of autocomplete function.

          – user10477251
          Nov 14 '18 at 12:50







          Yes but the only problem I got is the dot that's indeed getting picked up for some reason. The variables with a @ in front of it were all notice messages that didn't thwart things from happening. So I think it`s because of the explode part but I need that part to make it an sort of autocomplete function.

          – user10477251
          Nov 14 '18 at 12:50















          I suspect that's not the only problem. You're sending $domains to the batchCheckAvailability call, so what's in the $q parameter that you're exploding? It looks like you're working on $_REQUEST["q"], but then sending $_GET['domains'] to the API. I think you're going to need to clean up and simplify before the issue becomes obvious.

          – Morris
          Nov 14 '18 at 13:17





          I suspect that's not the only problem. You're sending $domains to the batchCheckAvailability call, so what's in the $q parameter that you're exploding? It looks like you're working on $_REQUEST["q"], but then sending $_GET['domains'] to the API. I think you're going to need to clean up and simplify before the issue becomes obvious.

          – Morris
          Nov 14 '18 at 13:17













          $q is like the erre in the picture, so like everything before the dot.

          – user10477251
          Nov 14 '18 at 13:21





          $q is like the erre in the picture, so like everything before the dot.

          – user10477251
          Nov 14 '18 at 13:21













          -1














          It surely seems like it. you're splitting an array with '.' in between them. if you want to get rid of that, just explode it with an empty string
          explode('', $q);






          share|improve this answer
























          • You cannot explode on an empty string.

            – jeroen
            Nov 14 '18 at 12:27











          • I need to explode it otherwise I couldn`t autocomplete the domain name after the dot.

            – user10477251
            Nov 14 '18 at 12:30











          • you can't explode an empty string, but you can explode a string with an empty delimiter, no?

            – Glenn van Acker
            Nov 14 '18 at 14:19
















          -1














          It surely seems like it. you're splitting an array with '.' in between them. if you want to get rid of that, just explode it with an empty string
          explode('', $q);






          share|improve this answer
























          • You cannot explode on an empty string.

            – jeroen
            Nov 14 '18 at 12:27











          • I need to explode it otherwise I couldn`t autocomplete the domain name after the dot.

            – user10477251
            Nov 14 '18 at 12:30











          • you can't explode an empty string, but you can explode a string with an empty delimiter, no?

            – Glenn van Acker
            Nov 14 '18 at 14:19














          -1












          -1








          -1







          It surely seems like it. you're splitting an array with '.' in between them. if you want to get rid of that, just explode it with an empty string
          explode('', $q);






          share|improve this answer













          It surely seems like it. you're splitting an array with '.' in between them. if you want to get rid of that, just explode it with an empty string
          explode('', $q);







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 14 '18 at 12:24









          Glenn van AckerGlenn van Acker

          115




          115













          • You cannot explode on an empty string.

            – jeroen
            Nov 14 '18 at 12:27











          • I need to explode it otherwise I couldn`t autocomplete the domain name after the dot.

            – user10477251
            Nov 14 '18 at 12:30











          • you can't explode an empty string, but you can explode a string with an empty delimiter, no?

            – Glenn van Acker
            Nov 14 '18 at 14:19



















          • You cannot explode on an empty string.

            – jeroen
            Nov 14 '18 at 12:27











          • I need to explode it otherwise I couldn`t autocomplete the domain name after the dot.

            – user10477251
            Nov 14 '18 at 12:30











          • you can't explode an empty string, but you can explode a string with an empty delimiter, no?

            – Glenn van Acker
            Nov 14 '18 at 14:19

















          You cannot explode on an empty string.

          – jeroen
          Nov 14 '18 at 12:27





          You cannot explode on an empty string.

          – jeroen
          Nov 14 '18 at 12:27













          I need to explode it otherwise I couldn`t autocomplete the domain name after the dot.

          – user10477251
          Nov 14 '18 at 12:30





          I need to explode it otherwise I couldn`t autocomplete the domain name after the dot.

          – user10477251
          Nov 14 '18 at 12:30













          you can't explode an empty string, but you can explode a string with an empty delimiter, no?

          – Glenn van Acker
          Nov 14 '18 at 14:19





          you can't explode an empty string, but you can explode a string with an empty delimiter, no?

          – Glenn van Acker
          Nov 14 '18 at 14:19


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53300077%2fhow-to-get-rid-of-the-dots%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          The Sandy Post

          Danny Elfman

          Pages that link to "Head v. Amoskeag Manufacturing Co."