Jump to content

salathe

Staff Alumni
  • Posts

    1,832
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by salathe

  1. This is for PHPMailer 6. This is for PHPMailer 5. Which version do you actually have?
  2. It looks like you're scraping pages from the PHP manual, so taking one of those as an example, the HTML looks like this (super-stripped down for simplicity): <?php $html = '<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> <!-- lots more goes here --> </html>'; $dom = new DOMDocument(); $dom->loadHTML($html); var_dump($dom->childNodes->length); foreach ($dom->childNodes as $childNode) { var_dump(get_class($childNode)); } The above outputs the following: int(2) string(15) "DOMDocumentType" string(10) "DOMElement" This shows that the document ($dom) has two child nodes: 1. the document type (<!DOCTYPE html>) and 2. the "html" element. Hope that helps. ?
  3. From the docs: This means that the expression you want to be matched is a single, text (string) value. If you're using a prepared statement, in PHP, with PDO, that means a single question mark (?) or a single ":name" placeholder if you're going for named parameters. A quick demo example: <?php $db = new PDO("sqlite::memory:"); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); $db->exec("CREATE VIRTUAL TABLE example USING FTS5 (a, b)"); $db->exec("INSERT INTO example (a, b) VALUES ('this is an amazing message', 'kittens are lovely')"); $db->exec("INSERT INTO example (a, b) VALUES ('this is a great message', 'dogs are also lovely')"); $db->exec("INSERT INTO example (a, b) VALUES ('this is a message', 'hamsters are best')"); $query = $db->prepare('SELECT * FROM example WHERE example MATCH ?'); $query->execute(array('(b: kittens) OR (a: great)')); $rows = $query->fetchAll(); print_r($rows); The above example outputs the two matching rows. Array ( [0] => Array ( [a] => this is an amazing message [b] => kittens are lovely ) [1] => Array ( [a] => this is a great message [b] => dogs are also lovely ) ) Hope that helps.
  4. A (very) brief note about Countable objects Classes implementing the Countable interface define and implement their own count() method. The DOMNodeList class is one such class. Instances of classes that implement the Countable interface can be passed to the count() function, and their own special count() method gets called. In DOMNodeList's case, that method returns the number of nodes in the list. There is nothing stopping you from calling the count() method on the object (e.g. $myobject->count()) rather than the count() function (e.g. count($myobject)), if that's what you want to do. How the heck am i supposed to count the childNodes? Back to your original question. There are several ways to get the number of nodes in a DOMNodeList (which is what your $dom->childNodes is). 1. $dom->childNodes->length 2. count($dom->childNodes) 3. $dom->childNodes->count()
  5. The mbstring regex functions are only similar by name. They use the Oniguruma regex engine to get the work done, not POSIX nor PCRE. Only the POSIX family of functions are deprecated at this time.
  6. No, the mbstring regex functions are not deprecated.
  7. Unfortunately, I can't. P.S. Maybe you're too new to realise that my previous P.S. was sarcastic in nature.
  8. Were you really hoping for us to come along and say, "Easy, framework XYZ is best."? Without context, it is not even possible to steer towards frameworks that might be useful to you, never mind the best of those! Is it the best at washing the dishes? Please, if you're going to make claims of suitability then at least be informative with it. P.S. quit spamming.
  9. The irony is, the person who moved it is not a member of staff.
  10. You could also replace the return statement in rajivgonsalves' function with the similarly functioning: return strspn(strtolower($word[0]), 'aeiou') ? 'an' : 'a';
  11. thorpe, the OP wants to be able to determine whether "an" or "a" should preceed a word. For example given the words apple, banana, orange the correct choices would be an, a, an respectively.
×
×
  • 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.