Skip to content

Tag: php

How to get database name in PDO?

Is there a function or constant within PDO that stores the database name (the testdb value) ? I did a var_dump on $dbh and cant find anything… Answer You could use the setAttribute() (essentially a key value pair) method to store the database name when you set it up initially, then use the getAttribute(…

Convert list into an array using php. How?

I have a function called listelements(), which outputs text like <li>text1</li><li>text2</li>. I have more than 500 elements. Now I want to convert it into an array. Can anyone help me? Thanks. Note: I’m using php Update: The thing i want to achieve is alphabetical navigation. As…

How long can a TLD possibly be?

I’m working on an email validation regex in PHP and I need to know how long the TLD could possibly be and still be valid. I did a few searches but couldn’t find much information on the topic. So how long can a TLD possibly be? Answer DNS allows for a maximum of 63 characters for an individual labe…

PHP if statements inside of echo to create HTML option list

I have a HTML option list of 10 numbers. I want one of these options to be pre-selected based on a value retrieved from a database. If the retrieved value is 0 or FALSE then value=”0″ should be selected, if the retrieved value is 1 then value=”1″ should be selected, etc. I have looked …