如果Transaction_No为0,如何在每个数组中搜索如果找不到条形码,则在下一个数组中跳过搜索。
预期结果: 0020000023120
Array(
[0] => Array
(
[Barcode] => 0020000021119
[Transaction_No] => 1
)
[1] => Array
(
[Barcode] => 0020000023120
[Transaction_No] => 0
)
[2] => Array
(
[Barcode] => 0020000023999
[Transaction_No] => 0
)
)
$customer = $response->ReadMultiple_Result->coupon;
foreach($customer as $value) {
if (current($value->Transaction_No) == "0") {
echo $value->Barcode.'</br>';
}
}
答案 0 :(得分:0)
你去吧
val nbSamplePerClass = /* some int value currently ranging between 50 and 10000 */
val onesDataFrame = inputDataFrame.filter("label > 0.0")
val zeros = inputDataFrame.except(onesDataFrame).collect()
val ones = onesDataFrame.collect()
val nbZeros = zeros.count().toInt
val nbOnes = ones.count().toInt
def randomIndexes(maxIndex: Int) = (0 until nbSamplePerClass).map(
_ => new scala.util.Random().nextInt(maxIndex)).toSeq
val zerosSample = randomIndexes(nbZeros).map(idx => zeros(idx))
val onesSample = randomIndexes(nbOnes).map(idx => ones(idx))
val samples = scala.collection.JavaConversions.seqAsJavaList(zerosSample ++ onesSample)
val resDf = sqlContext.createDataFrame(samples, inputDataFrame.schema)
答案 1 :(得分:0)
我得到的答案已经加上休息;所以它返回了事务0的最新数组条形码。
foreach ( $array as $value ) {
if ($value['Transaction_No'] == '0' ) {
echo $value['barcode'];
break;
}
}