$data= array();
$data[1]= Trial" Broker;
$data[2]= some'y Bank .
$data[3]=United ;States
My array contains lots of single, double quotes and semicolons in between the value and I don't want them.
This might help: replace them is enough.
I'm looking for the simplest function to perform this task please.
答案 0 :(得分:2)
You can iterate over the array and do a simple preg replace to strip out all characters other than a-z and 0-9
for ($i=0; $i < count($data); $i++) {
$data[$i] = preg_replace("/[^A-Za-z0-9?!]/", "", $data[$i]);
}
Be sure to set $i to the starting number of your array within the for loop above
$i=1; // in your given example
$i=0; // usually by default an array will start from 0
答案 1 :(得分:1)
尝试
#include<stdlib.h>
#include<string.h>
#include<stdio.h>
#include<ctype.h>
#include<locale.h>
int main () {
setlocale (LC_ALL,"UTF8");
FILE *puntafile;
char c, nome[30];
//Choosing file name
printf("Insert file name (Max 25 characters): ");
gets(nome);
while(strlen(nome) > 25)
{
printf("Too much long name!\n");
printf("Insert file name (Max 25 characters): ");
gets(nome);
}
//creation file name .vbs
char est[4];
strcpy (est,".vbs");
strcat (nome,est);
char testo[100];
//create the empty file
puntafile = fopen(nome,"w+");
//Insert the message
printf("Insert the note text (Max 100 characters): ");
gets(testo);
while(strlen(testo) > 100)
{
printf("Too much long text!\n");
printf("Insert the note text (Max 100 characters): ");
gets(testo);
}
//writing in the file...
char note[150];
//start text
strcpy(note,"msgbox \"");
//add the note text
strcat(note,testo);
//ending text
char closing[20];
strcpy(closing,"\" , \"6\" , \"Note\"");
strcat(note,closing);
//writing all in the .vbs file
fprintf(puntafile,"%s",note);
//end and close
printf("Note created!\n");
fclose(puntafile);
system("PAUSE");
}