Often times when coding in PHP, we have the need to turn an array into a comma separated string, or even an object into a comma separated string. As a Florida PHP Developer, I’d like to save you some time and show you the code.

Simple PHP array to comma separated string

$myArray = array(‘this’, ‘that’); $str = join(‘, ‘, $myArray); echo $str;

That’s the basic way of doing it. But what if you have an associated array?

Associated array to comma separated string

function to_string($data, $glue=’, ‘) { $output = ”; if(!empty($data) && count($data) > 0) { $values

Keeping software updated can be very time consuming because let’s face it, software runs our lives. Unless you’ve been living in the forest the past 20 years, you use software daily. As a Developer, I use phpMyAdmin, it’s my app of choice when managing databases because it runs smoothly, and it’s free. I love free, don’t you?

Now there comes a time in a Developer’s life when he/she needs to upgrade their phpMyAdmin installation. But since it’s one of those things that isn’t entirely “urgent” for the most part, security updates aside, we tend to put off upgrading until we

phpMyAdmin SSL – The “how to” you always wanted – but were too shy to admit to.

You should always use SSL with phpMyAdmin. Never leave a phpMyAdmin install insecure. Nowadays, you should secure phpMyAdmin with more than just SSL; like keeping phpMyAdmin SSL on its own private network. But that’s a different story entirely…

2 1/2 ways to force SSL with phpMyAdmin

1) Using Apache .htaccess (this can also be put in the httpd.conf if you don’t use .htaccess files):

RewriteEngine On RewriteCond %{SERVER_PORT} !^443$ RewriteRule ^/phpmyadmin(.*)$ https://%{HTTP_HOST}/phpmyadmin$1 [L,R]

or with nginx:

location /phpmyadmin { if ($ssl_protocol =

When you’re in there working your butt off, sometimes you have issues with what variables are available to you. For example, you might be working with some open source code like Drupal or WordPress, and you might not know based on the documentation what variables you have available to you. Here’s a way of finding that out with some simple PHP:

$vars = get_defined_vars(); var_dump($vars);

This will return a multidimensional array containing a list of all defined variables.

Why would I do this?

When coding a Drupal theme or a WordPress theme, you don’t always know what the

PHP is great. It complements JavaScript wonderfully. You may have already formatted the phone number on the front end, but what about on the backend? There comes a time when you need to use php to format a phone number (php format phone number). I use this function in my projects all the time.

PHP Format Phone Number Function

How to use php format telephone number:

function format_phone($country, $phone) { $function = ‘format_phone_’ . $country; if(function_exists($function)) { return $function($phone); } return $phone; } function format_phone_us($phone) { // note: making sure we have something if(!isset($phone{3})) { return ”; } // note:

When debugging your PHP code you often run into an issue where you’re trying to find the scope of what variables are available. Whether you’re taking over a project from someone, or you’re using a CMS or framework, being able to list in an array all the functions comes handy.

Here’s the simple PHP function to get all the functions available to you:

function myfunc() { echo ‘Hello World!’; } $list = get_defined_functions(); print_r($list);

This will output something like:

Array ( [internal] => Array ( [1] => func_num_args [2] => func_get_arg [3] => func_get_args [4] => strlen [5] => strcmp

PHP is by far our favorite programming language here at The Barton Organization. As a search engine optimization company in Florida, we use technologies like Laravel, WordPress & Drupal quite frequently.

In this little tutorial, we’re going to talk about how to validate a domain in PHP.

In order to validate a domain, the easiest way is to validate based on whether or not the domain is attached to an IP address or not. You can do regex to match the domain to a pattern, but then you need to keep a list of valid domain patterns. You can check

There comes a time in a programmers life when you want or need to grab the filename of a file, but not the file extension, while using PHP.

Here’s how to do just that:

$filename = pathinfo(‘./bin/myimage.jpg’, PATHINFO_FILENAME); echo $filename;

It comes in handy when you want to do something with the filename without having the file extension there to get in the way. Please use responsibly.

There comes a time when you want to check the ip address of a domain, you know, just in case you have the host file overridden or when you’re transferring a domain over to a new server. Here’s a little script to help you do that, and it’s based on PHP because that’s God’s programming language of choice.

#!/usr/bin/php <?php $opt = getopt(”, array(‘host:’)); if(isset($opt[‘host’])) { // get ip from host $host = starts_with($opt[‘host’], ‘http’) ? parse_url($opt[‘host’], PHP_URL_HOST) : $opt[‘host’]; $ip = gethostbyname($host); echo $ip . PHP_EOL; } else { // get internal ip for computer $ip = shell_exec(“/sbin/ifconfig |

There comes a time when you need to list files in a directory, but you only want certain files by extension. Here’s how you do that:

$files = glob(‘/your-path/your-directory/*.{png,gif,jpg,jpeg}’, GLOB_BRACE); if(count($files) > 0) { foreach($files as $file) { // DO SOMETHING HERE } }

The previous example will list all the images with extensions png, gif, jpg or jpeg. This works fine for the most part, but what if someone is a jerk and forgets the extension, or maybe they had the extension capitalized? Well, if it’s capitalized, you can just add that to the brackets, but if there isn’t

Find the Best SEO in Fort Lauderdale, Florida (Plantation SEO) | Drupal & Worpress Develpment