Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7998227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:09:51+00:00 2026-06-04T15:09:51+00:00

I have an array called as myArr . It contains strings and integers, e.g.

  • 0

I have an array called as myArr. It contains strings and integers, e.g.

0  st ts 0  0
st 0  0  0  0

For debugging the php script, I’m using Zend Studio. The debug window says that a cell [0][0] contains int 0. BUT the problem is that IF statement returns TRUE.

        for ($i = 0; $i < $rows; $i++) {
          for ($j = 0; $j < $cols; $j++) {
            if ($myArr[$i][$j] == 'ts' || $myArr[$i][$j] == 'st') {
                $num++;
            }
          }
        }

UPDATE: I’m running the code in Debug mode in Zend Studio. So, I can see that $num is increasing in each iteration. Also, I can see that cursor goes inside the loop

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T15:09:53+00:00Added an answer on June 4, 2026 at 3:09 pm

    When a string is compared to an integer, the string will be converted to an integer automatically and in your case the string has no digits so it will be evaluated to zero leading to satisfy the equality, you have two options:

    if ('0' == 'tr')

    OR

    if (0 === 'tr')

    were the === means check for the value and type.

    I also found this helpful for you from the PHP manual:

    The value is given by the initial portion of the string. If the string starts with valid numeric data, this will be the value used.
    Otherwise, the value will be 0 (zero)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have an array of strings in a php array called $foo with
Specifically, I have an array of strings called val, and want to replace all
I have an array (called array in the code below) which contains a number
I have a php array called $user. At the minute I am getting the
All, I have the following array called locations returned by a PHP ajax call
I have hardcoded array called users in a PHP function: protected static $users =
I have a 2D array called results. Each row array in results contains both
I have a array called $A which contains only non zero positive numbers. Now
I have any array called query[] I am opening a new window with: window.open(http://localhost:8081/myapp/Query.action,mywindow,menubar=1,resizable=1,width=600,height=400);
I have an array called as wcs declared using var wcs= new Array(); .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.