Remove Duplicate objects from JSON
//change is
while( $row = mysqli_fetch_array( $result ))
{
$response[] = $row;
}
//with this
while($row = mysqli_fetch_array($result))
{
$response['id'] = $row['id'];
$response['name'] = $row['name'];
$response['password'] = $row['password'];
$response['email'] = $row['email'];
}var json = [
{"text":"menu1","parent":"#","id":"128102"},
{"text":"menu1.1","parent":"128102","id":"128103"},
{"text":"menu1.1","parent":"128102","id":"128103"}
];
var ids = [];
var clean = [];
$.each(json, function(index, value) {
if($.inArray(value.id, ids) == -1)
{
ids.push(value.id);
clean.push(value);
}
});
Also in JavaScript:
- javascript list class properties
- array map
- reactstrap search bar
- firebase cloud functions send email
- add dev dependency yarn
- fire off some javascript on page load
- react redux middleware
- nested for loop javascript
- convert array to object in javascript
- adding element to array javascript
- jquery click hold down
- how to make a vowel counter in javascript
- javascript remove from array by index
- jquery select by data attribute
- nodejs generate ethereum address
- html button click only once
- javascript full screen div
- godot destroy node
- how to run cypress test
- emotion.sh keyframes
- set drawingmode javascript
- get parent element using jquery
- threejs
- how to fill array with consecutive numbers javascript