Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7609955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:18:08+00:00 2026-05-31T01:18:08+00:00

$str1 = HEADINGLEY; $str2 = HDNGLY; how can i seach string 1 to see

  • 0
$str1 = "HEADINGLEY";
$str2 = "HDNGLY";

how can i seach string 1 to see if it contains all the characters from string 2 in the order they exist in string 2 and return a true or false value ?

Any help appreciated 😀

if this helps, this is the code i have todate..

echo preg_match('/.*H.*D.*N.*G.*L.*Y.*/', $str1, $matches);

returns 0

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T01:18:10+00:00Added an answer on May 31, 2026 at 1:18 am

    I guess I’d use preg_match

    http://us.php.net/manual/en/function.preg-match.php

    …and turning $str2 into a regular expression using str_split to get an array and implode to turn it back into a string with ".*" as glue between characters.

    http://us.php.net/manual/en/function.str-split.php
    http://us.php.net/manual/en/function.implode.php

    Upate — I should have suggested str_split instead of explode, and here is the code that will get you a regular expression from $str2

    $str2pat = "/.*" . implode(".*", str_split($str2)) . ".*/";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm having 2 string array, str1[] = {a,b,aa,c} and str2[] = {aa,a,b,c,d} how can
Assuming I have the following strings: string str1 = Hello World!; string str2 =
I have my two select statements ( Str1 , Str2 ) in two string
Right now I have the following code: String[] values = {str1, str2}; Utils.myMethod(values); I
I have two strings: var str1 = '8***8***'; var str2 = '898-8293'; How can
I have the following variables: string str1 = 1; string str2 = asd; string
object obj = Hello; string str1 = (string)obj; string str2 = obj.ToString(); What is
we make the following String objects? String str1 = new String(ABC); String str2 =
String str1 =C:\Users\mehdi\Documents\NetBeansProjects\project1\src\res\1 (21).png ; String str2 = \res\1 (21).png; jLabel24.setIcon(new ImageIcon(getClass().getResource( ? )
I have a string: str1 = abcabcabc; How can I remove the first character?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.