473,320 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Problems with STRSTR function

Applogies for repost. For some reason the second half of my message
got chopped off... here's the full this agin (hopefully!)

I'm having a problem with the strstr function that is driving me up
the ?!**!?! wall!

OK, I hope the following sample code will illustrate the problem.

<?

$exif = read_exif_data_raw($HTTP_POST_FILES['image']['tmp_name'],0);

echo '<hr><b>Example 1</b><br>This is the test using fields from the
exif data<hr>';

$make=$exif['IFD0']['Make'];
$model=$exif['IFD0']['Model'];

echo "$make<br>";
echo "$model<br><br>";

if(stristr($model,$make))
{
echo "true<br><br>";
}
else
{
echo "false<br><br>";
}

echo '<hr><b>Example 2</b><br>This is the test using manual data<hr>';

$make="Canon";
$model="Canon EOS300D DIGITAL";

echo "$make<br>";
echo "$model<br><br>";

if(stristr($model,$make))
{
echo "true<br><br>";
}
else
{
echo "false<br><br>";
}

?>
And here is the out put:

Example 1
This is the test using fields from the exif data
Canon
Canon EOS 300D DIGITAL

false

Example 2
This is the test using manual data
Canon
Canon EOS300D DIGITAL

true

This is some code called by a form that uploads an image. In the first
example I am reading in two variables from the EXIF data using a
function from http://www.offsky.com/software/exif/index.php. I am then
comparing the contents of the two fields. the first field contains
"Canon" (in the variable $make) and the second contains "Canon EOS300D
DIGITAL" (in the variable $model). But for some reason it returns
false. In the second example I am entering exactly the same data into
the $make and $model variables manually. This time true is return as
expected. The echo statements confirm that the $make and $model
variable contain the same data in both examples. Can anyone offer an
explanation/solution and save my sanity??

Thanks in advance, Chris
Jul 17 '05 #1
2 3308
Probably a ASCII nul character (0) terminating the string stored in $make
(or possibly #x160)

--

"Chris" <cj**@blueyonder.co.uk> wrote in message
news:b7**************************@posting.google.c om...
Applogies for repost. For some reason the second half of my message
got chopped off... here's the full this agin (hopefully!)

I'm having a problem with the strstr function that is driving me up
the ?!**!?! wall!

OK, I hope the following sample code will illustrate the problem.

<?

$exif = read_exif_data_raw($HTTP_POST_FILES['image']['tmp_name'],0);

echo '<hr><b>Example 1</b><br>This is the test using fields from the
exif data<hr>';

$make=$exif['IFD0']['Make'];
$model=$exif['IFD0']['Model'];

echo "$make<br>";
echo "$model<br><br>";

if(stristr($model,$make))
{
echo "true<br><br>";
}
else
{
echo "false<br><br>";
}

echo '<hr><b>Example 2</b><br>This is the test using manual data<hr>';

$make="Canon";
$model="Canon EOS300D DIGITAL";

echo "$make<br>";
echo "$model<br><br>";

if(stristr($model,$make))
{
echo "true<br><br>";
}
else
{
echo "false<br><br>";
}

?>
And here is the out put:

Example 1
This is the test using fields from the exif data
Canon
Canon EOS 300D DIGITAL

false

Example 2
This is the test using manual data
Canon
Canon EOS300D DIGITAL

true

This is some code called by a form that uploads an image. In the first
example I am reading in two variables from the EXIF data using a
function from http://www.offsky.com/software/exif/index.php. I am then
comparing the contents of the two fields. the first field contains
"Canon" (in the variable $make) and the second contains "Canon EOS300D
DIGITAL" (in the variable $model). But for some reason it returns
false. In the second example I am entering exactly the same data into
the $make and $model variables manually. This time true is return as
expected. The echo statements confirm that the $make and $model
variable contain the same data in both examples. Can anyone offer an
explanation/solution and save my sanity??

Thanks in advance, Chris

Jul 17 '05 #2
My guess is that the data is stored as Unicode-16. Do a strlen() on $make
and $model and see if they're not longer than you expected.

Uzytkownik "Chris" <cj**@blueyonder.co.uk> napisal w wiadomosci
news:b7**************************@posting.google.c om...
Applogies for repost. For some reason the second half of my message
got chopped off... here's the full this agin (hopefully!)

I'm having a problem with the strstr function that is driving me up
the ?!**!?! wall!

OK, I hope the following sample code will illustrate the problem.

<?

$exif = read_exif_data_raw($HTTP_POST_FILES['image']['tmp_name'],0);

echo '<hr><b>Example 1</b><br>This is the test using fields from the
exif data<hr>';

$make=$exif['IFD0']['Make'];
$model=$exif['IFD0']['Model'];

echo "$make<br>";
echo "$model<br><br>";

if(stristr($model,$make))
{
echo "true<br><br>";
}
else
{
echo "false<br><br>";
}

echo '<hr><b>Example 2</b><br>This is the test using manual data<hr>';

$make="Canon";
$model="Canon EOS300D DIGITAL";

echo "$make<br>";
echo "$model<br><br>";

if(stristr($model,$make))
{
echo "true<br><br>";
}
else
{
echo "false<br><br>";
}

?>
And here is the out put:

Example 1
This is the test using fields from the exif data
Canon
Canon EOS 300D DIGITAL

false

Example 2
This is the test using manual data
Canon
Canon EOS300D DIGITAL

true

This is some code called by a form that uploads an image. In the first
example I am reading in two variables from the EXIF data using a
function from http://www.offsky.com/software/exif/index.php. I am then
comparing the contents of the two fields. the first field contains
"Canon" (in the variable $make) and the second contains "Canon EOS300D
DIGITAL" (in the variable $model). But for some reason it returns
false. In the second example I am entering exactly the same data into
the $make and $model variables manually. This time true is return as
expected. The echo statements confirm that the $make and $model
variable contain the same data in both examples. Can anyone offer an
explanation/solution and save my sanity??

Thanks in advance, Chris

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Chris | last post by:
I'm having a problem with the strstr function that is driving me up the ?!**!?! wall! OK, I hope the following sample code will illustrate the problem. <? $exif =...
6
by: Marco Chiarandini | last post by:
Dear all, I am experiencing a problem in the deallocation of STL data structures. In paritcular I create a vector of sets and insert integers in each set. I do not define any deallocator since...
12
by: Lars Langer | last post by:
Hi there, I'm new to this C - never the less - I'm trying to search a string for the occurence of a substring - However, I'm not very succesful since my use of the strstr function always returns...
4
by: Hugh | last post by:
Hello, I am having some problems understanding (most likely), parsing a text file. I would like to parse a file like: block1 { stuff; ... stuffN; };
24
by: John Smith | last post by:
How to test whether strstr() returns a null pointer or not? Do I use something like the following? if(NULL != strstr(str1,str2)) That does not seem to work.
5
by: OzBob | last post by:
Am performing the following check to determine if a set of text is at the start of a string,.... /* Check for literal text DD at beginning of string date_format */ char date_format; if...
4
by: smnoff | last post by:
I am trying to use the strstr function but it doesn't seem to work with a dynamically allocated string that I pass into a function. Specifically, I am using a Macromedia C-level extensibility and...
13
by: Kelvin Moss | last post by:
Hi all, How could one write an strstr function to work with unicode characters? Are there existing implementations/solutions/api for doing so? Any pointers would be appreciated. Thanks ..
6
by: linq936 | last post by:
Hi, I have the following code: #include <stdio.h> int main(void){ char* str1 = "abc"; char* str2 = '\0'; if ( strstr(str1, str2) == NULL ){ printf("yes\n");
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.