jQueryの情報やプラグイン公開しています

JavaScript plug-in to realize (jQuery) to pirnt_r of PHP

JQuery plugin that adds to the object the same functionality as the print_r function of PHP.
I think that was created from, but good if the JavaScript is the same as it is so very easy to use print_r.
So I thought (arbitrarily) that think that I can be realized even without a jQuery separately if you tweak something, in recent years and that the industry standard jQuery, that it would be more convenient to the jQuery plug-in and if so You have to make the layers.

Reference

We have reference to the following sites. Or that expansion portion of the array is the copy nearly round, we stuck to the output of the look.
dump () - Javascript equivalent of PHP's print_r () function

Function

  1. Expand the easy to read user-defined arrays and objects. *
  2. Can be output in a way specified by ID display and alert.

Etc. * jQuery object or object does not parse HTML. Only user-defined array or object only (such as JSON data).

How to use

$. Prnt_r (obj, target)

obj
User-defined arrays and objects.
target
The output destination.
output () alert: true
Output to the object with the specified id: "id"

If it is omitted, adding the body element (the default)

Sample

// sample1
var array = new Array("sun", "mon", "tue", "wed", "thu", "fri", "sat");
$.print_r(array);

// target省略の場合、body要素の最後に追加
Array
(
    [0] => sun
    [1] => mon
    [2] => tue
    [3] => wed
    [4] => thu
    [5] => fri
    [6] => sat
)

// sample2
var array = new Array("So <long>",'JavaScript', "PHP", "HTML","Hello <World>");
$.print_r(array, true);

// alert(メッセージボックス)で表示
Array
(
    [0] => So <long>
    [1] => JavaScript
    [2] => PHP
    [3] => HTML
    [4] => Hello <World>
)

// sample3
var f = function(data) {
	return data;
}
var assoc = {
	"val"  : "New",
	"number" : 8,
	"array" : array,
	"fnc" : f
};

$.print_r(assoc, "comment");

// 指定ID(comment)に出力
Object
(
    [val] => New
    [number] => 8
    [array] =>
        Array
        (
            [0] => So <long>
            [1] => JavaScript
            [2] => PHP
            [3] => HTML
            [4] => Hello <World>
        )
    [fnc] => function (data) {
    return data;
}
)

ダウンロード

- DownLoad(182)

その他注意事項

何かしらのトラブルが発生しても当社が責任を負うことは一切ありませんので、使用する場合は自己責任でお願いします。

更新履歴

2011-08-22 ver1.0 公開

タグ
, , , ,
トラックバックURL

Leave a Reply

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

*

次のHTML タグと属性が使えます: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

ページTOPに戻る