Is there an equivalent function in PHP for unix cut -f? -
i have long string of values separated tabs , wish cut data if using unix cut -f. if use cut -f5 cuts data single column of value in 5th position. there php function can same?
below example of raw file each word in row separated tab
the result follows if ran cut -f2:
i guess answer "no", far know. can combine few php functions achieve same result.
you can use file read lines file array
$rows = file($path_to_your_file); then convert array of strings multidimensional array
$rows = array_map(function($row){ return str_getcsv($row, "\t"); }, $rows); then column want array.
$column_5 = array_column($rows, 4); not concise cut -f5, php things this.
incidentally, if don't care php program work on systems have unix cut, can use cut -f in shell_exec.


Comments
Post a Comment