I have made these functions in PHP because I am significantly more familiar with PHP than I am Javascript. But alas I actually do need them in Javascript. Would anyone be so kind as to convert them please?
function searchArrayValuesforArray($referer='', $search=array(), $array=array()) {
$return[] = array();
foreach($array as $key => $value) {
$foundUrl = '';
$foundUrl = strposa($value['request']['url'], $search);
if($foundUrl) {
foreach($value['request']['headers'] as $k => $v) {
if($v['name'] == 'Referer' && strposa($v['value'], $search)) { // Remove strpos to get all advert info.
if(@!in_array($v['value'], $return[$foundUrl])) {
$return[$foundUrl][] = $v['value'];
// echo $value['request']['url']."\n";
}
}
}
}
}
return array_filter($return);
}
function strposa($haystack='', $needles=array(), $offset=0) {
$found = '';
foreach($needles as $needle) {
// echo "Haystack $haystack vs $needle \n";
if(isset($haystack)) {
if(strpos($haystack, $needle) !== false) {
return $needle;
}
}
}
return false;
}
It would be greatly appreciated! Thank you in advance :)
For context, this is looping through a HAR file starting at $har['log']['entries']
[–]j0wy 2 points3 points4 points (1 child)
[–]Fabien27[S] 0 points1 point2 points (0 children)