in Education by
Recently I asked a question regarding preg_match_all with php, and i got the perfect solution as expected but now I have some different scenario here is my string : $html = '

This is my Home Page.

{{ type="slider" pagename="slider-1" }} {{ type="banner" pagename="banner-1" }} {{ type="testimonial" pagename="testimonial-1" }}

'; My Code : preg_match_all('/{{ type="(.+?)" }}/', $html, $matches, PREG_SET_ORDER); echo "
";

print_r($matches);

foreach ($matches as  $val) {

    echo $val[1];

    echo "

"; } ?> Result i am getting : Array ( [0] => Array ( [0] => {{ type="slider" pagename="slider-1" }} [1] => slider" pagename="slider-1 ) [1] => Array ( [0] => {{ type="banner" pagename="banner-1" }} [1] => banner" pagename="banner-1 ) [2] => Array ( [0] => {{ type="testimonial" pagename="testimonial-1" }} [1] => testimonial" pagename="testimonial-1 ) ) slider" pagename="slider-1 banner" pagename="banner-1 testimonial" pagename="testimonial-1 How can i get the values for slider and pagename variable written in {{ and }} in the string ? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Here: /{{ type=\"(.+)\"\s+pagename=\"(.+)\" }}/i In action: https://regex101.com/r/tX9vD3/1

Related questions

0 votes
    Any data written in double quotes is a numeric constant true / false Select the correct answer from above options...
asked Dec 23, 2021 in Education by JackTerrance
0 votes
    I think I have an error in my code here - $('#form input[type=radio]').val();. JS: $( ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    I think I have an error in my code here - $('#form input[type=radio]').val();. JS: $( ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    I think I have an error in my code here - $('#form input[type=radio]').val();. JS: $( ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    I think I have an error in my code here - $('#form input[type=radio]').val();. JS: $( ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    I am using fb features on my website. I am able to get FB profile pics of the users from ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    I am using fb features on my website. I am able to get FB profile pics of the users from ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    What is difference between including the header file with-in angular braces < > and double quotes “ “?...
asked Jan 17, 2021 in Technology by JackTerrance
0 votes
    What is difference between including the header file with-in angular braces < > and double quotes “ “?...
asked Jan 17, 2021 in Technology by JackTerrance
+1 vote
    What is difference between including the header file with-in angular braces < > and double quotes “ “?...
asked Nov 9, 2020 in Technology by JackTerrance
+1 vote
    What is the behavioral difference when the header file is included in double-quotes (“”) and angular braces (<>)?...
asked Nov 8, 2020 in Technology by JackTerrance
0 votes
    I have a $_GET[q] from the URL. I am trying to ECHO the search term back into the search box. ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 6, 2022 in Education by JackTerrance
0 votes
    I have a $_GET[q] from the URL. I am trying to ECHO the search term back into the search box. ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 4, 2022 in Education by JackTerrance
0 votes
    I am trying to deserialize a JSON string but I get an error: var response = jss.Deserialize(responseValue) ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    I am trying to deserialize a json string received as a response from the service. The client is Windows ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
...