Note that there are some explanatory texts on larger screens.

plurals
  1. POIf array equal array PHP
    primarykey
    data
    text
    <p>Is possible to make <code>if($array1[0]=&gt;somevalue == $array2[0]=&gt;somevalue){echo true;}else{echo false;}</code>? because I cant make it work, can you help me please,</p> <p>Example: $array1([0] => 'Joe', [2] => 'Pairs'); $array2([0] => 'info' => array([0] => 'joe'));</p> <pre><code>foreach($array2-&gt;info as $info){ foreach($array1 as $name){ if($name == $info[0]){ echo 'true'; } else{ echo 'false'; } } } </code></pre> <p>And this is the real code,</p> <p>The arrays: </p> <pre><code> Array ( [0] =&gt; SimpleXMLElement Object ( [companyLocationInfo] =&gt; Array ( [0] =&gt; SimpleXMLElement Object ( [companyName] =&gt; AVIS [name] =&gt; NYCC07 [line1] =&gt; 420 EAST 90TH STREET ) [2] =&gt; SimpleXMLElement Object ( [companyName] =&gt; AVIS [name] =&gt; NYCC06 [line1] =&gt; 310 EAST 64TH STREET ) [3] =&gt; SimpleXMLElement Object ( [companyName] =&gt; AVIS [name] =&gt; NYCC01 [line1] =&gt; 68 EAST 11TH STREET ) ) [rates] =&gt; Array ( [0] =&gt; SimpleXMLElement Object ( [pickupDropoffLocations] =&gt; Array ( [0] =&gt; SimpleXMLElement Object ( [companyName] =&gt; AVIS [name] =&gt; NYCC07 ) ) [vehicleRentalPrefType] =&gt; CCAR [rateAmount] =&gt; 83.99 [rateCurrency] =&gt; USD ) [2] =&gt; SimpleXMLElement Object ( [pickupDropoffLocations] =&gt; Array ( [0] =&gt; SimpleXMLElement Object ( [companyName] =&gt; AVIS [name] =&gt; NYCC06 ) ) [vehicleRentalPrefType] =&gt; CCAR [rateAmount] =&gt; 110.54 [rateCurrency] =&gt; USD ) [3] =&gt; SimpleXMLElement Object ( [pickupDropoffLocations] =&gt; Array ( [0] =&gt; SimpleXMLElement Object ( [companyName] =&gt; AVIS [name] =&gt; NYCC01 ) ) [vehicleRentalPrefType] =&gt; CCAR [rateAmount] =&gt; 210.65 [rateCurrency] =&gt; USD ) ) ) </code></pre> <p>)</p> <p>and this is the code:</p> <pre><code>$results_array = array(); foreach($result[0]-&gt;rates as $rate) { foreach($result[0]-&gt;companyLocationInfo as $info) { if($info-&gt;name == $rate-&gt;pickupDropoffLocations[0]-&gt;name) { $results_array[] = array( 'line1' =&gt; $info-&gt;line1, 'name' =&gt; $info-&gt;locationDetails-&gt;name, 'companyName' =&gt; $info-&gt;companyName, 'vehicleRentalPrefType' =&gt; $rate-&gt;vehicleRentalPrefType ); } } } print_r($results_array); </code></pre> <p>Thank you.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload