I printed array witch is sent by Xcode using following code in php

$handle = fopen('php://input','r');  
$jsonInput = fgets($handle);  
$decoded = json_decode($jsonInput,true);  
print_r($decoded);  

This is how array looks like when printed:  
Array
(
    [json] => Array
        (
            [0] => Array
                (
                    [price] => 380
                    [name] => SPICY TANDOORI CHICKEN
                    [desc] => Toasted sesame seed bun with grilled tandoori marinated chicken, onions, capsicums topped with cheese and mayo. Served with french fries
                )

            [1] => Array
                (
                    [price] => 380
                    [name] => SPICY TANDOORI CHICKEN
                    [desc] => Toasted sesame seed bun with grilled tandoori marinated chicken, onions, capsicums topped with cheese and mayo. Served with french fries
                )

            [2] => Array
                (
                    [price] => 380
                    [name] => SPICY TANDOORI CHICKEN
                    [desc] => Toasted sesame seed bun with grilled tandoori marinated chicken, onions, capsicums topped with cheese and mayo. Served with french fries
                )

        )

)

I want to add this array to mysql database. how can I insert. help me :(

share|improve this question
1  
use foreach to read all values and then prepare your INSERT query... – Akam Mar 12 at 10:06
1  
what have you tried? – Yogesh Suthar Mar 12 at 10:07
looks like a rather monotonous diet – Mark Baker Mar 12 at 10:13
thanks for reply :) i dont know how get data from the array to insert query. can anybody help me – user2160335 Mar 12 at 10:22

closed as not a real question by hakre, Yogesh Suthar, Ocramius, PLB, Till Helge Helwig Mar 12 at 10:09

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, see the FAQ.

1 Answer

Simply use foreach loop to insert the data into database

share|improve this answer
thanks for quick reply :) what i cant understand is how to get array data to variables. can you help me ? – user2160335 Mar 12 at 10:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.