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
https://forums.phpfreaks.com/topic/257416-unknown-reason-for-a-value-in-an-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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