XML-RPC array int problem

Discussion in 'PHP' started by 2ge, Dec 15, 2008.

  1. #1
    Hello all,

    I am using xmlrpc-epi v. 0.51/PHP Version 5.2.8. My problem is really weird. I need return this array (don't ask why, it is just example):
     
    Array
    (
        [3387112] => 3387112
        [3385570] => 3385570
    )
     
    Code (text):
    here is my PHP code:
     
    function foo() {
        $in = array("3387112","3385570");
     
        $data = array();
     
        foreach($in as $value) {
            $data[ (string) $value ] = "$value";
        }
     
        return $data;
    }
     
    Code (text):
    output is:
     
    Array
    (
        [0] => 3387112
        [1] => 3385570
    )
     
    Code (text):
    which is wrong. If somebody can help me, how to put INTEGERS as keys in output array, I will be really happy, or give me some help, I am really stuck. I tried double quotes, (string), strval and so on, I can not put any INT in output, I am not sure, if it is error of XMLRPC-EPI or...?
     
    2ge, Dec 15, 2008 IP
  2. SISKO

    SISKO Peon

    Messages:
    9
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    $in = array(3387112=>"3387112",3385570=>"3385570");
     
    SISKO, Dec 15, 2008 IP
  3. 2ge

    2ge Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    SISKO: Thanks for answer, but it won't help. Are you using XMLRPC in PHP, or you are just guessing ? Also my code is not wrong, tell me why there is [0] and [1] in my output. If you can, try it in XMLRPC (EPI)
     
    2ge, Dec 15, 2008 IP
  4. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #4
    its working fine
    function foo() {

    $in = array("3387112","3385570");



    $data = array();



    foreach($in as $value) {

    $data[ (string) $value ] = "$value";

    }



    return $data;

    }

    echo "<pre>";
    print_r(foo());
    echo "</pre>";
     
    bartolay13, Dec 15, 2008 IP
  5. SISKO

    SISKO Peon

    Messages:
    9
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    nope, i guessed it XMLRPC was some kind of script for php, my bad...but if this doesn't work like normal php i think you would get more help in the main programming forum
     
    SISKO, Dec 15, 2008 IP
  6. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #6
    ahh.. i get it.. i thought the function is wrong... hahaha
    i will replicate the same function in xml-rpc.. sorry bout that
     
    bartolay13, Dec 15, 2008 IP
  7. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #7
    are you using any mvc frameworks?
     
    bartolay13, Dec 15, 2008 IP
  8. juust

    juust Peon

    Messages:
    214
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #8
    return array($data);
    might fix it, explicitly returning an array
    the xml-rpc library should then use a struct tag to transport the array.
     
    juust, Dec 16, 2008 IP
  9. ConceptsInsight

    ConceptsInsight Greenhorn

    Messages:
    89
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    18
    #9
    I've got a community website powered by elgg (elgg dot org). I want users to be able to register to that community site from a different website. I found a plugin that allows this. But installing the plugin requires knowledge of xml-rpc, which I don't have. Would anyone like to give it a try? PM me with your fee. Cheers.
     
    ConceptsInsight, Jan 1, 2011 IP