Hi bro, last days I couldn’t keep online but I’am planning two guides step to step
The first is how to custom results printing value of variables and this another how to handle json because I didn’t see it here and it is common to be used
I realize that a lot of the doubts I had, and do, are recurring doubts about someone new to OB but is getting harder
for those who have already tested from A - Z with all kinds of config, that is, people with a lot of experience, these doubts may even seem meaningless
When you study something for the first time, you’ll probably have doubts that a old user doesn’t can ever seen
As I am new on ob2 and actually learning how to solve this kind of problem I can do both, so I will start make these guides whenever possible
Well, about the topic, how I can handle json arrays?
Here is my example, this is an search
input = 91021:ruri smart
$myobj = json_decode($start, true);
foreach( $myobj['news'] as $value){
$dvalue= $value['number'];
$name= $value['name'];
$pos = strpos($dvalue, $find);
if ($dvalue === false) {
echo json_encode(array("status" => 1, "msg" => "$dvalue|$name Not Found<br>"));
}else{
echo json_encode(array("status" => 0, "msg" => "$dvalue|$name Found<br>"));
break;
}}
The returned value will be:
Array
(
[code] => 200
[locatedresults] => Array
(
[0] => Array
(
[number] => 0691021
[name] => Ruri smart
)
[1] => Array
(
[number] => 0526021
[name] => Ruri OB2
)
To access this values from this arrays I only see two ways
$variable1isname = $json['locatedresults']['0']['name'];
or
use foreach as I used in the code above
A name can be equal, but with different number
My input slice is number:name to avoid it. I need match if the input number will contain in result, also with name.
My question actually is
-
How to get value from array [0] [name] if this ID change to 1 2 3 4 5 6 7 8 9…, I do not can get results from array ID
-
Some way to discard the entire result and keep only the needed? I’m getting an huge entire DOM response each HIT
I could continue using out ob but I want bring my tools to OB because of this stability, I can have all in one place.
thx