Jump to content

Unknown reason for a value in an array


EchoFool

Recommended Posts

Hey

 

 

I have a script that builds an array but for some reason there is a loose integer in the variable which is confusing me and i think its the cause of my syntax errors in javascript. But i got no idea where it is coming from =/

 

 

Here is the function i use:

 

<?php
function img($id) {
      $img = array();
      $img['tiles'] = $this->db->getAll("SELECT DISTINCT t.id, CONCAT('data/tiles/',filename) AS f FROM `map_tiles` AS mt
               INNER JOIN `tiles` AS t ON (mt.tile=t.id)
                WHERE mt.map_id={$this->db->qstr($id)}");

      echo print_r($img); 
      die;            
      //exit(json_encode($img)); // turned off for testing
?>

 

 

The echo returns this:


Array
(
    [tiles] => Array
        (
            [0] => Array
                (
                    [id] => 10
                    [f] => data/tiles/floor.png
                )


        )

)
1  <----- why does this appear? And could this cause a syntax error if sent back for JS processing?

 

 

As you can see there is 1 showing at the end but i don't see why =/ Any ideas if thats suppose to happen ?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.