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 6917125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:41:27+00:00 2026-05-27T09:41:27+00:00

I have this PHP: $ec = $trimmed[’emails’];//has a value of email $dc = $trimmed[‘date’];//has

  • 0

I have this PHP:

$ec = $trimmed['emails'];//has a value of "email"
$dc = $trimmed['date'];//has a value of "timestamp"

$data = array("email","domain","timestamp");

$num = count($data);

for ($i=0; $i<$num; $i++){

    if ($data[$i] == $ec) {
        $ec = $i;
    } else if ($data[$i] == $dc) {
        $dc = $i;
    }    
}

When I run this PHP $ec ends up equaling the location of domain and not email. Also, it is clear that the first if thinks both “email” and “domain” are equivalent to “email” because when I echoed out the loop the first time it shows $ec as “email”. Any ideas why?

  • 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-05-27T09:41:27+00:00Added an answer on May 27, 2026 at 9:41 am

    Because on the second iteration $ec (which is now 0) is compared with "domain", which evaluates to true, proven with a simple var_dump( 0 == "domain");, which outputs true.

    As William Van Rensselaer suggests below, you can either use ===, or check out the function array_search, which will accomplish exactly what you’re trying to do.

    Example:

    $ec = array_search( $data, $trimmed['emails']);
    $dc = array_search( $data, $trimmed['date']);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this php code line $data['viewData']['filter'] = isset($parameters['filter']) ? $parameters['filter'] : array('filter1', 'filter2',
I have this php code: $lines = file(data.csv); $nested = array(); $links = array();
I have this php code $jsonArray = array(); $sql = SELECT ID,CLIENT FROM PLD_SERVERS;
I have this PHP snippet: <?php $colors = array('red','green','blue'); foreach ($colors as &$item) {
I have this PHP code - <?php for($i=1; $i<=1000; $i++) { $array=array(); $array[$i]=54*$i; $arr=array($array[$i].,);
I have this php code and the variable is XML data $strXML = <chart
I have this php code: $images=array(); $root = $_SERVER['DOCUMENT_ROOT'].'SV'; for ($i=1; $i<=$total_pics; $i++){ $images[]=$root.'/ad_images/'.$category.'/thumbs/'.$id_stripped.'_'.$i.'.jpg';
I have this php code $ids = array(1,2,3); $names = array(cat,elephant,cow); $originalSettings = array
I have this PHP one dimensional array: Array ( [Female--N] => 11 [Male--N] =>
I have this PHP-script which I'd like to keep unchanged: $display = array( 'QDATETIME',

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.