When I run the following code: echo $_POST['zipcode']; print_r($lookup->query($_POST['zipcode'])); ?> the results are concatenated on one line like so: 10952Array. How can I get it...
echo "
";

seen from Canada
seen from China
seen from United States
seen from Palestinian Territories
seen from United States
seen from United States
seen from China
seen from United States
seen from Netherlands

seen from United States
seen from India
seen from United States
seen from Spain

seen from United States
seen from United States
seen from United States
seen from Romania
seen from TΓΌrkiye
seen from United States

seen from Poland
When I run the following code: echo $_POST['zipcode']; print_r($lookup->query($_POST['zipcode'])); ?> the results are concatenated on one line like so: 10952Array. How can I get it...
echo "
";

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch β’ No registration required β’ HD streaming
javascript μμ phpμ print_r() μ΄λ var_dump() μνμ νλ ν¨μ
function dump(obj) { var out = ''; for (var i in obj) { out += i + ": " + obj[i] + "\n"; }
alert(out);
// or, if you wanted to avoid alerts...
var pre = document.createElement('pre'); pre.innerHTML = out; document.body.appendChild(pre) }
This mess is the result of the methods that I tested and wrote tonight. The part above the line is the JSON encoded response that is echoed out for use by the front-end code. The part below the line is just the result decoded and output in a readable format using print_r().
Just like that, this is ready to use and be tested with. Either another method in the controller, or parameters for this action method will allow the list to be filtered by customer. But that is for another night.
[javascript] Printing objects to html
In testing I found it annoying that Javascript objects could only be viewed fully in the console, so I created this function that sort of mimics the old PHP print_r() function. It even includes indentation. I'm sure it could be improved further but works pretty well for me :)
Usage:
I turned this method into an easy to use jQuery plugin. If you want to use this feature in your own JSFiddles then include this script on your page. The usage syntax of the jQuery version is as follows.
$.print_r(myObject);
or
var printed = $.print_r(myObject, {autoAppend: false});