<?php
/**
* Replaces values in a dataset with a timeout for development purposes.
*
* @param array $data The dataset to modify.
* @param int $timeout The timeout in seconds.
* @return array The modified dataset.
*/
function replaceWithTimeout(array $data, int $timeout): array
{
$modifiedData = [];
foreach ($data as $key => $value) {
if (is_numeric($value)) {
//Convert to string to apply timeout function.
$modifiedData[$key] = str_replace(strval($value), 'TIMEOUT', $key) . 'TIMEOUT';
} else {
$modifiedData[$key] = 'TIMEOUT'; //Replace non-numeric values with TIMEOUT
}
}
return $modifiedData;
}
// Example usage:
//$dataset = [1, 2, 'abc', 4, 5];
//$timeout = 5;
//$modifiedDataset = replaceWithTimeout($dataset, $timeout);
//print_r($modifiedDataset);
?>
Add your comment