Problem with strpos and preg_match

Hi there,

I need help with these functions. My experience with php is very limited but I have been doing C programming decades ago so the principle is known to me.

ultimately I want to create a program that can compare 2 files, file1 is a list of part no. and prices, file2 a tech manual with only part no. and extract the prices of file1 for all the part no. of file2.

I am in the early stages but now for hours stuck with the 2 functions, both of which do not work as expected.

I am certain identical part no. are in both files so both functions should find matches but they do not.

the code is here:

Your regular expression needs to be wrapped in delimiters to work. You can use different characters, but / is popular:

$part_no1 = "/^[0-9]{6}$/";

I can’t see you file contents so I can’t be sure, but this should allow your script to match.

If you enable PHP errors on your script, you would have seen a warning that would help with this. You can do this by including:

ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');

at the top of your script.

1 Like

thank you for your help !!

I have incorporated your suggestions in both variants but to no avail. I do not get any screen error messages and the output in both cases is identical:

1.txt exists
1.csv exists
an input error has occured
end program

i have uploaded 1.csv (the file with & price) and 1.txt (a txt file derived from a pdf, looking awful but that does not matter because all I need it to verify if the exists within this file)

so if you want to have a look, that would be appreciated:

the updated code is here:

Sponsor our Newsletter | Privacy Policy | Terms of Service