如何从数组中显示变量

时间:2016-03-12 10:49:54

标签: php arrays

我正在尝试从数组中显示变量。我已经尝试过但不能正常工作。 我的代码

<?php
    $quesid = array();
    $quid = $_POST["qid"];
    print_r($quid);
    foreach ($que as $quid) {      
        $quesid = $que[0][$j];
        echo $quesid;
    }
?>

这不起作用。 但是print_r($quid);显示了数组元素:

 Array ( ['1'] => 54 ['2'] => 55 ['3'] => 56 ['4'] => 57 ['5'] => 58 ['6'] => 59 ['7'] => 60 ['8'] => 64 ['9'] => 65 ['10'] => 66 ['11'] => 76 ['12'] => 77 ['13'] => 78 )

2 个答案:

答案 0 :(得分:0)

manager.startAccelerometerUpdates()
    manager.accelerometerUpdateInterval = 0.1
    manager.startAccelerometerUpdatesToQueue(NSOperationQueue.mainQueue()){
        (data, error) in

        let currentX = self.Player.position.x

        if data!.acceleration.x < 0 {
            self.destX = currentX + CGFloat(data!.acceleration.x * 1000)
        }

        else if data!.acceleration.x > 0 {
            self.destX = currentX + CGFloat(data!.acceleration.x * 1000)
        }

        print(currentX)
    }

override func update(currentTime: CFTimeInterval) {
    /* Called before each frame is rendered */

    let action = SKAction.moveToX(destX, duration: 0.1)
    self.Player.runAction(action)
}

答案 1 :(得分:0)

您的foreach表达式顺序错误:

<?php 
$quids = $_POST["qid"]; 
foreach ($quids as $k=>$quid){ 
    echo $quid."<br>"; 
}
?>