Here we are solving a basic problem faced by a beginner web developer in PHP i.e.How to change file group in PHP .

Sample code

<?php
$filename = "shared_file.txt";
$format = "%s Group ID @ %s: %d\n";
printf($format, $filename, date("r"), filegroup($filename));
chgrp($filename, 8);
clearstatcache(); // do not cache filegroup() results
printf($format, $filename, date("r"), filegroup($filename));
?>

chgrp attempts to change the group of the file filename to group.

Syntax

bool chgrp ( string $filename , mixed $group )

Parameters

1) filename

Path to the file.

2) group

A group name or number..

Note: This function will not work on remote files as the file to be examined must be accessible via the server's filesystem.