0

I have this php array

$var = $var = explode("[;;]",$result['infoplantilla']);
$numRow = count($var); 
$form = array
        (
            "numRow",$numRow,
            "selectOption",$var,
            "prefijo",$result['prefijo'],
            "Sufijo",$result['sufijo'],
            "Plantilla",$result['descripcion']
            );

echo  json_encode($form);

So when I try to return this to the ajax call it return me value something like this .

["numRow",2,"selectOption",["baners.Idbaner= INMOMEXICO.ANUNCIO.ID"," monedas.Idmoneda= INMOMEXICO.ANUNCIO.MONEDA"],"prefijo","MXSAEI","Sufijo","-14","Plantilla","SAE"]

Which is not a Json string can any one help me out where I am going wrong because supposedly I should get a Json string from the array

Thanks in Advance

1 Answer 1

3

The problem is that your array is NOT an associative array.

Try this:

$form = array
        (
            "numRow" => $numRow,
            "selectOption" => $var,
            "prefijo" => $result['prefijo'],
            "Sufijo" => $result['sufijo'],
            "Plantilla" => $result['descripcion']
         );
Sign up to request clarification or add additional context in comments.

6 Comments

Yes sure after 10 minutes :) Stack won't let me mark it now
@Vikram , please dont make unnecessary comments.Only useful comments should remain below the answer.
@RahulDesai one last question in Jquery I understood I will have to use var obj = jQuery.parseJSON( json ) but how I can get the multidimentional array ? , Like when i write Obj.selectOption it returns me a string that has all the values of that array so Its difficult to use then ;
@Vikram Sorry, your question is not clear to me. Please post a new question on StackOverflow and link me to it so I can help you. Also, if you can add a jsFiddle demonstrating the problem, that would be helpful. :)
@RahulDesai jsfiddle.net/Vicky_Anand/4wg9oqor here is the fiddle for my problem ; thanks
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.