Skip to content
Advertisement

Tag: preg-match-all

Acessing values from preg_match_all in PHP 7.4

I am trying to access the values from the results of preg_match_all. Below is my coding: Below is the results of ensuring there are values: This my attempt to access the page location, i.e. 465,5400 etc.. I have tried various ways and (3 indices and 4 indices).I always end up with an error message – Array to string conversion error.

Get multiple values from preg_match_all and use of foreach

I have tried to find a solution for my specific problem. I have a regex where I find two specific values. These values need to be combined in a foreach loop. String So I have this regex used with preg_match_all to fetch the alt text and the image itself: I can fetch the results individually by using print_r($matches[1]); and print_r($matches[2]);

How can i replace all specific strings in a long text which have dynamic number in between?

I am trying to replace strings contains specific string including a dynamic number in between. I tried preg_match_all but it give me NULL value Here is what i am actually looking for with all details: In my long text there are values which contains this [_wc_acof_(some dynamic number)] , i.e: [_wc_acof_6] i want to convert them to $postmeta[‘_wc_acof_14’][0] This can

PHP RegEx preg_match_all Reiterate Matched Words Before the Current Match

I have the following RegEx code I expect the matches to include: word1 word2 word3 keyword word4 word5 word6 word4 word5 word6 keyword word7 word8 word9 But in reality, I’m getting these: word1 word2 word3 keyword word4 word5 word6 keyword word7 word8 word9 In other words, the second match is cropped because of the 1st match. Here’s a test: https://regex101.com/r/EPp14b/1/

Weird array structure in preg_match_all output PHP

I have pregmatch_all function that scrapes emails ! But the output is kind of weirdly structured and I don’t manage to restructure it. returns Two things please: How can I get rid of the “com” array ? How can I restructure the array in order to get : Array ( [0] => hello@soshape.com ) Any idea ? (if my question

Advertisement