Checking for a Match - Identifying if a string contains any characters from a different string

Is there a way to verify if a string contains any characters other than those listed below?

A-Z 0-9 / \ - _ . ( ) space

Answer №1

My solution utilized the following approach:

if (!preg_match("/^[A-Za-z0-9-_.:()/\\ ]+$/", $string)) {

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The coin_change function appears to be functioning properly for specific values

I created a function that determines the number of different coins I should receive based on the amount entered. However, it appears that the function is only working for specific amounts. For example, if I input $5.1, I should get 5($1) and 1(1cent). But ...

What is causing this code to malfunction?

Currently delving into the world of Ajax, I've been following a tutorial and have crafted the script below: <!DOCTYPE html> <html> <head> <script type="text/javascript"> function MyFunction(){ var xmlhttp; if(windo ...

Modify the background color using PHP

I want to change the background color of the ImageCreateTrueColor function to white and then overlay an image on it. if(($height>50)&&($width<50)) { $img_r = imagecreatefromjpeg($new_img_path); $source = ImageCreateTrueColor(50, 50); im ...

Using ext.js to make asynchronous AJAX requests

Could someone help me with a question? I have the code below that I found from a certain source: Ext.Ajax.request({ url: 'http://localhost/day1/new.php', method:'GET', params:{format:'json'}, success: this. ...

Using MAMP and PHP in the Terminal

After setting up MAMP and using PHP successfully, I also tried running PHP commands in Terminal. However, now I am facing an issue where Terminal is unable to find the PHP command: "Terminal / PHP command not found" This has left me unable to work on any ...

Creating a custom button in PHP

Currently, I am in the process of developing a shopping cart feature. One key requirement is to send both the product ID and the desired quantity chosen by the user to another file named cart.php. Below is an excerpt from my code snippet: for($i=0;$i< ...

What is the best way to eliminate the additional square bracket from a JSON file containing multiple arrays?

Seeking JSON data from an array, I encountered an issue with an extra square bracket appearing in the output. After attempting $episode[0] = $podcast->getPodcastByCategoryId($id);, only partial data was retrieved, corresponding to the first iteration. ...

Class Mapping Titles

I'm attempting to extract the values of attributes and elements from an XML response using a PHP SOAP client. I've been trying to utilize classmap, but haven't had any success so far... SOAPCLIENT: $client = new MySoapClient(null, array(&a ...

Upon submission of the form, trigger an email to be sent and simultaneously open a

I need my form to simultaneously open a window and send the form data via email when submitted. <form action="" method="post" id="form" onsubmit="paymentfunc();return false;"> Submit button: <input type="submit" value="Purchase" class="btn" id= ...

Uploading an image to an Oracle database with the help of PHP and AJAX

Looking for a way to insert an image into an Oracle database using OCI with PHP, Ajax, and jQuery. I've searched online but couldn't find any examples. If anyone has a solution, please share. Thanks in advance. <la ...

Steps to Show New Blog Entries on WordPress Homepage Only After Clicking a Link

When a specific tab is clicked on the WordPress blog home page, the following process should be initiated. The content should be displayed using AJAX for a smoother user experience. For instance, in the blog homepage, there are three tabs titled "They Li ...

PHP's for loop may not iterate through the entire array

I am currently using PHP/7.2.0beta3 and I have a requirement to develop a custom function in PHP that can reverse an array. For example, if the array is (1,2,3), the desired outcome should be (3,2,1). My initial approach was to utilize the array_pop funct ...

Show loading message on keypress using jQuery

I need assistance with a unique jQuery script for the desired functionality: While inputting text into the text field, I would like the adjacent 'Load' text to be displayed. If typing stops, the 'Load' text should change to 'Del& ...

Showing additional content in an alternative design

I'm currently facing an issue with the "load more" post button on my Wordpress site. I've designed a unique grid layout for the category page, with a load more button at the bottom. However, when I click the button to load more posts, they appear ...

The count in the document is not increasing

I am facing an issue where a file on the server contains a counter, and when a link is clicked, an ajax request is sent to a PHP file to increment the counter in the file. However, the file is being created without the counter being incremented. Interesti ...

Is it possible for me to generate values using PHP that can be easily read by JavaScript?

I'm currently building a website and I am facing some challenges when trying to incorporate JavaScript for real-time calculations. Here are my issues: Is there a more efficient way to avoid manually typing out the code for each level up to 90, lik ...

How to easily open a search page with just a click on the search field in CodeIgniter?

I am in the process of implementing a search feature in CodeIgniter. My view file is divided into two main sections: Header section, which includes the search bar <?php echo form_open('controller/live_search');?> <div class="toolba ...

loading images from a server in a dynamic manner within a list view on an Android application

I'm relatively new to android development and I've created a database with different user profiles, each containing an image URL. Now, I want to fetch the image URLs from the database for a specific user and display them in an Android ListView. ...

Employing ajax for handling a request from a dynamically created roster

I'm encountering an issue with deleting records from a database using a PHP loop. I want to remove records without having to refresh the page, but I'm struggling to implement this feature. Currently, I have a span element (styled as a bootstrap ...

Performing calculations on PHP and MySQL data within an HTML table, enabling precise percentage

Here's the code I'm currently working with: <td> <?php echo $row['feild1'] + $row['feild2'] + $row['feild3'] + $row['feild4'] + $row['feild5'] + $row['feild6'] + $row[' ...