John Davidson

Compare a string and a php array and only show the matches

0 comments
Message:


I have a string that looks like this:


"illustration,drawing,printing"

I have an array that looks like this:


Array (
[0] => illustration
[1] => drawing
[2] => painting
[3] => ceramics
)

How can I compare the two and only display the terms that exist in both the string and array?


So in the above example, I would want to output something that looks like this:



SKILLS: illustration, drawing



Thank you!



My Answer:
"I love coding in PHP and JavaScript"

_I also have a PHP array that looks like this:_

php
$array = array("PHP", "JavaScript", "Python", "Java");


_The matches between the string and the array are:_

- PHP
- JavaScript

Rate this post

5 of 5 based on 7311 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us