How to identify the result is an array or associative array

Actually result is coming from mysql_query(), it results sometimes array or sometimes associative array how to identify it.


You actually get an object from mysqli_query(), which can either be converted into an associative array with mysqli_fetch_assoc($mysqli_obj) or an array with mysqli_fetch_array($mysqli_obj).

But to determine if a variable is an associative array:

function isAssoc($obj) {
    if(is_object($obj)) {
        $array = get_object_vars($obj);
    else {
        $array = $obj;
    return (count(array_filter(array_keys($array), 'is_string'))) ? true : false;

Need Your Help

link rewrite in htaccess file for SSL connection

php .htaccess ssl

I'm using a php book to build a ecommerce site. It gives instructions to rewrite the htaccess file so that the site uses an SSL connection on certain pages. This is the code it gives.

How to set <body> tag as fixture in Jasmine

testing jasmine fixtures stubbing jasmine-jquery

I'm currently trying to test a JS function with Jasmine. Since the function checks for CSS classes set in the body tag, I want to use the tag in a fixture: