Check if first occurrence of string has an a tag before it

115
September 08, 2018, at 11:40 PM

I have created a script that goes through all my WordPress posts and replaces the first occurrence of a word with a link.

The problem I'm having is if I were to submit the form again the code will add double links.

I'm trying to work out a way to check if there is an A tag before the keyword/phrase.

The problem lies if the keyword exists in the URL replacement

for example,I replaced the word Tesco with a href of www.tesco.com - Tesco

I have a check that gets the position of the first character of my keyword/phrase and then minus 1 and checks if this is a > sign (if there was a tag before it there would be a > closing the open tag).

This works if the keyword/phrase doesn't exist in the URL but fails if it does exist in the URL.

is there a way to look for the first occurrence of a keyword/phrase and keep going back until I find the first space/tab and then check if there's an a tag between the space/tab and the start of the keyword?

I hope this makes sense.

thanks Ian

READ ALSO
About php7 Uniform Variable Syntax, nested functions

About php7 Uniform Variable Syntax, nested functions

I'm try to solve a task which uses new functions php7 uniform variable syntax nested () support foo()() (https://wikiphp

118
Is PHP's password_hash FIPS compliant?

Is PHP's password_hash FIPS compliant?

I believe hash('sha256', $pw) is FIPS compliant, but I know for certain that an attack vector is possible with using that functionAlso, there is no salt (so I would have to encounter that implementation and I would rather not)

64
Find the number of orders related to each order size in MySQL

Find the number of orders related to each order size in MySQL

Need some help with a MySQL query to be used in a larger databaseSimplified here, I need to find the number of orders related to each order size

118
Nested SELECT, or am I over-complicating?

Nested SELECT, or am I over-complicating?

I have the following tables:

67