Jump to content

MoFish

Members
  • Posts

    219
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

MoFish's Achievements

Advanced Member

Advanced Member (4/5)

0

Reputation

  1. @NotionCommotion Thank you for all your help, i fixed the issue. It was the \r as you suggested which was causing the issue.
  2. @NotionCommotion You are correct, some nulls are coming back but i don't understand why there would be no response message with them. $textAr: ["www.google.com\r","www.bbc.com\r","www.sky.com"] $line: google.com bool(false) $line: bbc.com bool(false) $line: sky.com string(203) " status error error Domain sky.com already registered " array(3) { ["www.google.com "]=> bool(false) ["www.bbc.com "]=> bool(false) ["www.sky.com"]=> string(203) " status error error Domain sky.com already registered " }
  3. @NotionCommotion I was hoping for something like this, as each of these are already registered. However, only get the last response
  4. $textAr: ["www.google.com\r","www.yahoo.com"] $line: www.google.com $line: www.yahoo.com status error error Domain yahoo.com already registered Array ( [0] => [1] => status error error Domain yahoo.com already registered ) Its like the second request blanks out the first. If i do three requests, i only ever get the last one. $textAr: ["www.google.com\r","www.yahoo.com\r","www.bbc.com"] $line: www.google.com $line: www.yahoo.com $line: www.bbc.com status error error Domain bbc.com already registered Array ( [0] => [1] => [2] => status error error Domain bbc.com already registered )
  5. @NotionCommotion $line: www.xxx2.com $textAr: ["www.xxx1.com\r","www.xxx2.com"] Array ( [0] => [1] => status error error The domain xxx2.com already exists in our database. This may occur if there is a pending Order for xxx2.com in our database under your account or any other account. You may search for this domain within your control panel.) $result = array(); foreach ($textAr as $line) { $url = "https://example.com/api/domains/blah.xml?domain-name={$line}"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true ); curl_setopt($ch, CURLOPT_ENCODING, "gzip,deflate"); $result[] = curl_exec ($ch); curl_close ($ch); } printf('$line: %s'.PHP_EOL, $line); printf('$textAr: %s'.PHP_EOL, json_encode($textAr)); print_r($result);
  6. xxx1.com xxx2.com Array ( [0] => [1] => status error error The domain xxx2.com already exists in our database. This may occur if there is a pending Order for xxx2.com in our database under your account or any other account.) As you can see, its only getting the result from the last one for some reason.
  7. Hi @requinix Apologies i removed that URL bit to simplify it. The $line is passed into the url of the curl call so each is unique. When using the below code and calling 3 curl requests for example; it only gets the last string response even if i try to append. I cannot figure out whats going on! if (isset($_POST['submit'])) { $result = array(); foreach ($textAr as $line) { $url = "https://xxx.com/api/domains/meh.xml?auth-userid=xxx&domain-name={$line}"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true ); curl_setopt($ch, CURLOPT_ENCODING, "gzip,deflate"); $result = curl_exec ($ch); // $result[] = curl_exec ($ch); curl_close ($ch); print_r($result); } // print_r($result); }
  8. Hi, It returns a string like the following: string(506) " status error error The domain xxx.co.uk already exists in our database. This may occur if there is a pending Order for xxx.co.uk in our database under your account or any other account." I would like to collate all these return strings for each of the curl request (could be 10+) and return them as an alert/echo at the end of them all. if (isset($_POST['submit'])) { $result = array(); foreach ($textAr as $line) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true ); curl_setopt($ch, CURLOPT_ENCODING, "gzip,deflate"); $result = curl_exec ($ch); curl_close ($ch); var_dump($result); } // i would like all of the strings to be compiled into one for returning to the screen // but it seems like it only gets the last one instead of them all, even if i try string appending. // is there a way to wait until one is completed before the next? } Thank you for your help.
  9. Hello, I am trying to do multiple curl requests and get the response for each one output to the screen. I have wrote the following code, but only appear to be getting the last response when outputting $result. What am i doing wrong? Is there a way to wait for each curl request to be completed before appending to $result so I can see them all? Thanks very much if (isset($_POST['submit'])) { $result = array(); foreach ($textAr as $line) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true ); curl_setopt($ch, CURLOPT_ENCODING, "gzip,deflate"); $result[] = curl_exec ($ch); } curl_close ($ch); echo "<pre>"; print_r($result); echo "</pre>"; }
  10. Hi All, I have mark-up which contains many {{edit:xxx}} tags this is inside a variable called $html I'm trying to find all these edit tags and displaying the name, but am not sure best how to achive it. For example my $html contains: {{edit:top}} {{edit:bottom}} {{edit:left}} {{edit:right}} I want to create a $results array with the following values: top bottom left right Many thanks, MoFish
  11. Hi requinix, Thanks for your reply. I may look at parsing the document for items in double braces instead, hopefully that makes things a little simpler. Cheers, MoFish <img src='{{source}}' label='{{label}}' help="{{help}}" />
  12. Hi, I am trying to use DOMdocument to find <edit> tags in my HTML. When I use an <edit> tag on it's own it works fine and finds all the information I require On the odd occasion, I am required to put my <edit> tags inside quotes (as per my second example commented out) which falls over. I'm assuming it does not like the quotes and is bombing out Can anyone shed some light on if this is possible? or will this simply not work with the DOMdocument due to it's structure? I understand its' not the norm. Many Thanks, MoFish <?php // works $html = "<edit name='source' label='Source' help='boom' />"; // doesnt work // $html = "<img src='<edit name='source' label='Source' help="boom" />' />"; $dom = new DOMDocument(); $dom->loadHTML($html); $edits = $dom->getElementsByTagName('edit'); foreach ($edits as $edit) { foreach ($edit->attributes as $attr) { echo "Name '$attr->nodeName' | Value '$attr->nodeValue'<br />"; } } ?>
  13. Hi, I am looking to alter this slightly and am not sure how best to go around it. What I am now trying to do is: Set a start date e.g first day of January (2017-01-01) Set a end date e.g last day of December (2017-12-31) Find the number of weeks between the two date ranges (2017-01-01, 2017-12-31) which returns 52 weeks. And the tricky bit - for each of these 52 weeks - find the weeks startdate (Monday this week) and enddate (Friday this week). I have got the first three steps working using the function below, but am a little unsure on how best to find out the start date and end dates of these particular 52 weeks. I am maybe over thinking it, but i cannot understand gow best to tackle the next steps - as am unsure on how to find out a single date in each week. Any help much appriciated. MoFish function datediffInWeeks($start, $end) { if($start > $end) return datediffInWeeks($end, $start); $sd = DateTime::createFromFormat('Y-m-d', $start); $ed = DateTime::createFromFormat('Y-m-d', $end); return floor($sd->diff($ed)->days/7); // foreach of these weeks // find the start date 'Monday this week' // find the end date 'Friday this week' // return an array } var_dump(datediffInWeeks('2017-01-01', '2017-12-31')); // 52
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.