-
Content Count
1,832 -
Joined
-
Last visited
-
Days Won
3
salathe last won the day on March 7
salathe had the most liked content!
Community Reputation
40 GoodAbout salathe

-
Rank
Badger
Contact Methods
-
Website URL
http://cowburn.info
Profile Information
-
Gender
Male
-
Location
Edinburgh, Scotland
Recent Profile Visitors
3,694 profile views
-
email address is domain account user name @ the server name
salathe replied to Chrisj's topic in PHP Coding Help
This is for PHPMailer 6. This is for PHPMailer 5. Which version do you actually have? -
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. 🙂
-
PDO. How to pass quote literal as part of query?
salathe replied to nik_jain's topic in PHP Coding Help
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. -
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()
-
Unfortunately, I can't. P.S. Maybe you're too new to realise that my previous P.S. was sarcastic in nature.
-
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.
-
You could also replace the return statement in rajivgonsalves' function with the similarly functioning: return strspn(strtolower($word[0]), 'aeiou') ? 'an' : 'a';
-
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.