Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

--TEST-- Test filter expression with equals number for bracket notation with star --SKIPIF..

Decoded Output download

--TEST--
Test filter expression with equals number for bracket notation with star
--SKIPIF--
<?php if (!extension_loaded("jsonpath")) print "skip"; ?>
--DESCRIPTION--
This test case is allowed by the grammar but is semantically ambiguous. When
an expression operand resolves to a non-scalar value, the first element in the
set is used for comparison. In this case, the following comparisons are made:

1 == 2
2 == 2
1 == 2
2 == 2
1 == 2
--FILE--
<?php

$data = [
    [
        1,
        2,
    ],
    [
        2,
        3,
    ],
    [
        1,
    ],
    [
        2,
    ],
    [
        1,
        2,
        3,
    ],
    1,
    2,
    3,
];

$jsonPath = new \JsonPath\JsonPath();
$result = $jsonPath->find($data, "$[?(@[*]==2)]");

var_dump($result);
?>
--EXPECT--
array(2) {
  [0]=>
  array(2) {
    [0]=>
    int(2)
    [1]=>
    int(3)
  }
  [1]=>
  array(1) {
    [0]=>
    int(2)
  }
}

Did this file decode correctly?

Original Code

--TEST--
Test filter expression with equals number for bracket notation with star
--SKIPIF--
<?php if (!extension_loaded("jsonpath")) print "skip"; ?>
--DESCRIPTION--
This test case is allowed by the grammar but is semantically ambiguous. When
an expression operand resolves to a non-scalar value, the first element in the
set is used for comparison. In this case, the following comparisons are made:

1 == 2
2 == 2
1 == 2
2 == 2
1 == 2
--FILE--
<?php

$data = [
    [
        1,
        2,
    ],
    [
        2,
        3,
    ],
    [
        1,
    ],
    [
        2,
    ],
    [
        1,
        2,
        3,
    ],
    1,
    2,
    3,
];

$jsonPath = new \JsonPath\JsonPath();
$result = $jsonPath->find($data, "$[?(@[*]==2)]");

var_dump($result);
?>
--EXPECT--
array(2) {
  [0]=>
  array(2) {
    [0]=>
    int(2)
    [1]=>
    int(3)
  }
  [1]=>
  array(1) {
    [0]=>
    int(2)
  }
}

Function Calls

None

Variables

None

Stats

MD5 1499809f2df7dd616ea112641fdd1fa0
Eval Count 0
Decode Time 111 ms