Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

i have a doubt about sending php array to another php file using ajax-jquery, if we send the php array via jquery post using some input type hidden value , it's convert array as string. so the another php file not receiving as array value it's receiving as a string. i know php explode implode function for that. but in codeiginter the given array is differ see the following array i need to send

Array ( [0] => stdClass Object ( [pro_id] => 1731 [pro_code] => 2564 [pro_name] => Lakudi [pro_des] =>  IS USED IN ALL FOOD SWEETNER INSTEAD OF SUGAR [pro_det_des] => ALSO AVAILABLE VARIES COLORS AND SHAPES CUBES BIG AND SMALL BALLS AND YELLOW, BROWN AND BLACK COLORS [pro_pack_des] => BULK AS WELL AS CONSUMER PACKING CAN BE OFFERED 30 KGS BULK ALSO AVAILABLE [pack_length] => 65 [pack_breadth] => 85 [pack_height] => 110 [cbm] => 0.608 [case_netweight] => 30 [case_grossweight] => 31 [price_INR] => 1100.00 [price_USD] => 0.00 [slab1] => [slab2] => [slab3] => [slab4] => [s1price] => [s2price] => [s3price] => [s4price] => [prolabel] => [exp_on] => 2013-12-31 [und_grp] => 16 [image_name] => 19442_94.jpg [image_name1] => 0 [image_name2] => 0 [image_name3] => 0 [crt_date] => 2013-06-11 [up_date] => 2013-06-11 [status] => active [admin_status] => deactive [list] => 0 [supplier_id] => 100 [bin] => 0 ) )  

i was send this array using input type hidden sample code

<input type="hidden" class="datapro" value="<?php print_r($data)?>">

my jquery-ajax code

$('.clickfu').click(function(){
        var view = $(this).attr('id');      
        var datapro = $('.datapro').val();
        $.post('<?php echo base_url()?>productajax',{typ:'proview',view:view,datapro:datapro},function(data){                                               
             $(".prolist").replaceWith(data);
            // alert(data);
        });
        return false;
    })

in this array. how can i use explode implode function to convert the string as array. so please kindly give me guidance for solve this issue. thanks advance

share|improve this question
    
Using <?php print_r($data)?> to set value of input is NOT a good idea, never, ever! –  Hashem Qolami Jun 27 '13 at 13:50
1  
I think you might want to use json_encode, which takes a php object/array and turns it into a json object string. I'm not entirely sure what you are trying to though. –  KJ Price Jun 27 '13 at 13:52
    
i want to just post as a array and get as a array. how can i do this in jason_encode. give me some example –  TamilArivu Jun 27 '13 at 13:56
1  
@tamil_arvu take a look at this and this and also the PHP Doc –  Hashem Qolami Jun 27 '13 at 14:00
    
thanks hashem quolami –  TamilArivu Jun 27 '13 at 14:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.