Skip to main content

Search within associative array

Search within associative array
this is value -- pc..5 Parent
this is column -- $data['user_name']
Array
(
    [0] => Array
        (
            [id] => 12
            [user_name] => Tintin-PC..1 Parent
            [port] => 744
            [ip] => 122.162.235.239
            [source] => India
            [type] => 1
            [version] => 1
        )

    [4] => Array
        (
            [id] => 25
            [user_name] => pc..5 Parent
            [port] => 264
            [ip] => 115.249.8.245

            [source] => India
            [type] => 1
            [version] => 5
        )

array_search('pc..5 Parent', array_map(function($data) {return $data['user_name'];}, $arrayofparents));

Comments

Popular posts from this blog

Error: ios-deploy was not found. Please download, build and install version 1.9.0 or greater from https://github.com/phonegap/ios-deploy into your path, or do 'npm install -g ios-deploy' solution this solved the issue sudo npm install -g ios-deploy -unsafe-perm

Error: ios-deploy was not found. Please download, build and install version 1.9.0 or greater from https://github.com/phonegap/ios-deploy into your path, or do 'npm install -g ios-deploy' solution this solved the issue sudo npm install -g ios-deploy -unsafe-perm

How to upload file in MEAN Stack

How to upload file in MEAN Stack Do these steps 1. npm install ng-file-upload 2. include ng-file-upload.min.js in your angular index .html 3. Use this example to copy form to your angular page from where u want to upload file. -- http://jsfiddle.net/0m29o9k7/ or http://jsfiddle.net/danialfarid/2vq88rfs/136/ Copy this code outside of any form which is already there: 4. Change this url from example code to where you want to upload files -- url: 'https://angular-file-upload-cors-srv.appspot.com/upload', 6. In your server.js or app.js which ever you are using as (node server.js) to start app add these lines     var crypto = require('crypto');         var mime = require('mime');         var multer  = require('multer');                     var storage = multer.diskStorage({           destination: function (req, file, cb) {     ...

Send push motification to iphone and android code

Send push motification to iphone and android code function sendIphoneAdminPush($token,$message) { $streamContext = stream_context_create(); $badge = 0; //$message = "Here is the new deal having 50% discount for business ABC."; //$token = "ghjkghkgkghkghkjghkghkghjkhkghkghjkhkhgjkhgj"; stream_context_set_option($streamContext, 'ssl', 'local_cert', $_SERVER['DOCUMENT_ROOT'].'/nodatapp/pem/pushNew.pem'); $apns = stream_socket_client( //'ssl://gateway.sandbox.push.apple.com:2195', 'ssl://gateway.push.apple.com:2195', $error, $errorString, 60, STREAM_CLIENT_CONNECT, $streamContext); $load = array(   'aps' => array(   'alert' => $message,   'badge' => $badge,   'sound' => 'default',   'data' => array( 'push_type' => "IphonePush" )   )   ); $payloa...