Batıkan Genç ACAT Batıkan Genç ACAT - 5 months ago 19
PHP Question

How Can I Select Data by Name From Array in PHP?

I have an array like this:

Array(
[0]=>Array([uploaderName]=>btknctTR[uploadedImageName]=>k6gIjfO[uploaderIp]=>195.155.116.217[uploaderMac]=>e0699587cbfd[uploadedServer]=>alpha)
[1]=>Array([uploaderName]=>btknctTR[uploadedImageName]=>byUTyJo[uploaderIp]=>195.155.116.217[uploaderMac]=>e0699587cbfd[uploadedServer]=>alpha)
[2]=>Array([uploaderName]=>btknctTR[uploadedImageName]=>oSVEnNk[uploaderIp]=>195.155.116.217[uploaderMac]=>e0699587cbfd[uploadedServer]=>alpha)
[3]=>Array([uploaderName]=>btknctTR[uploadedImageName]=>Dj7GRYS[uploaderIp]=>195.155.116.217[uploaderMac]=>e0699587cbfd[uploadedServer]=>alpha)
[4]=>Array([uploaderName]=>btknctTR[uploadedImageName]=>upsb8IC[uploaderIp]=>195.155.116.217[uploaderMac]=>e0699587cbfd[uploadedServer]=>alpha)
[5]=>Array([uploaderName]=>btknctTR[uploadedImageName]=>YoEEzGi[uploaderIp]=>195.155.116.217[uploaderMac]=>e0699587cbfd[uploadedServer]=>alpha)
[6]=>Array([uploaderName]=>btknctTR[uploadedImageName]=>st3dLNs[uploaderIp]=>195.155.116.217[uploaderMac]=>e0699587cbfd[uploadedServer]=>alpha)
[7]=>Array([uploaderName]=>btknctTR[uploadedImageName]=>LBNpiIG[uploaderIp]=>195.155.116.217[uploaderMac]=>e0699587cbfd[uploadedServer]=>alpha)
[8]=>Array([uploaderName]=>btknctTR[uploadedImageName]=>mFYDmBG[uploaderIp]=>195.155.116.217[uploaderMac]=>e0699587cbfd[uploadedServer]=>alpha)
[9]=>Array([uploaderName]=>btknctTR[uploadedImageName]=>z03kSx1[uploaderIp]=>195.155.116.217[uploaderMac]=>e0699587cbfd[uploadedServer]=>alpha)
)


I want to get any image's data from this array.

Example: When user shows
uploadedImageName == jCPjeWv
, I wan't to get who is it's uploader.

Answer

Simple, just use foreach

$arr = array(/* content here */);

foreach($arr as $value){
    if($value['uploadedImageName'] == 'jCPjeWv'){
        echo $value['uploaderName'];
        break;
    }
}
Comments