a need to parse file names to cli

i have a php script where i need to create a zip archive with an array of file names

so I do this running zip via php; using shell_exec().

i hit a bump when it comes to files which has names like

/var/www/someone's file (3)

cause my zip command looks like

shell_exec("zip -r -j myzip.zip /var/www/someone's file (3)");

now i need a way to parse the file names so it looks like

/var/www/someone\'s\ file\ (3)

any help on this is much appreciated and is there any function which can do this directly ?

Answers


You're looking for escapeshellarg().


Need Your Help

How to kill stack activity

android android-activity

Please tell me any one, how to kill previous stacked activity.My requirement is like that

How do I connect to an .mdf (Microsoft SQL Server Database File) in a simple web project?

c# asp.net database visual-studio-2008

Specifically, in VS 2008, I want to connect to a data source that you can have by right-clicking on the automatically-generated App_Data folder (an .mdf "database"). Seems easy, and it is once you ...