On PHP >5.4, This function will usually create any subfolders inside the ZIP archive.
For instance:
$zip->addFromString ( 'path/to/file.txt' , $data );
will create the folders "path/", and "path/to/" in addition to placing the newly created file "file.txt" in "path/to/" folder.