Delete value by key in user meta array in WordPress
I've this array set to a WordPress user on my WordPress page:
Array
(
[0] => Array
(
[0] => 1509
[1] => 1597
)
)
To receive this array I'm doing this:
$get_ids = get_user_meta( 3, 'additional_ids', false );
So good, so far! Now I've a little problem because for example I need to remove the value 1509 from the user_meta
. So I thirst tried to find out the key by the value which works good for the moment:
$key = array_search( (int) $value, $get_ids[0], true );
So I've found out now that the key is [0]
. But how can I delete this now a smart way from the user meta and save it that my meta data array looks like this after saving it:
Array
(
[0] => Array
(
[0] => 1597
)
)
This is what I've tried:
//Unset element to delete from the array
unset( $get_ids[0][ $key ] );
//Save it again in the database
update_user_meta( 3, 'additional_ids', $get_ids, false );
But when I do this the array is totally messed up and not longer readable.
php arrays wordpress multidimensional-array
add a comment |
I've this array set to a WordPress user on my WordPress page:
Array
(
[0] => Array
(
[0] => 1509
[1] => 1597
)
)
To receive this array I'm doing this:
$get_ids = get_user_meta( 3, 'additional_ids', false );
So good, so far! Now I've a little problem because for example I need to remove the value 1509 from the user_meta
. So I thirst tried to find out the key by the value which works good for the moment:
$key = array_search( (int) $value, $get_ids[0], true );
So I've found out now that the key is [0]
. But how can I delete this now a smart way from the user meta and save it that my meta data array looks like this after saving it:
Array
(
[0] => Array
(
[0] => 1597
)
)
This is what I've tried:
//Unset element to delete from the array
unset( $get_ids[0][ $key ] );
//Save it again in the database
update_user_meta( 3, 'additional_ids', $get_ids, false );
But when I do this the array is totally messed up and not longer readable.
php arrays wordpress multidimensional-array
Means, there are chances of multiple arrays and you dont want to specify$get_ids[0]
right?
– Shashidhara
Nov 26 '18 at 6:49
There is just one first array [0] thats because I'm working with 0 here. And I want to remove a child from this parent array in my meta_data field I named in the question. And I don't care the way it should just work. If it's possible to do it without a bug function it would be better but I needs to work for the moment.
– Mr. Jo
Nov 26 '18 at 6:53
Usearray_pop($get_ids[0]);
. Note: it always removes first element.
– Shashidhara
Nov 26 '18 at 6:58
add a comment |
I've this array set to a WordPress user on my WordPress page:
Array
(
[0] => Array
(
[0] => 1509
[1] => 1597
)
)
To receive this array I'm doing this:
$get_ids = get_user_meta( 3, 'additional_ids', false );
So good, so far! Now I've a little problem because for example I need to remove the value 1509 from the user_meta
. So I thirst tried to find out the key by the value which works good for the moment:
$key = array_search( (int) $value, $get_ids[0], true );
So I've found out now that the key is [0]
. But how can I delete this now a smart way from the user meta and save it that my meta data array looks like this after saving it:
Array
(
[0] => Array
(
[0] => 1597
)
)
This is what I've tried:
//Unset element to delete from the array
unset( $get_ids[0][ $key ] );
//Save it again in the database
update_user_meta( 3, 'additional_ids', $get_ids, false );
But when I do this the array is totally messed up and not longer readable.
php arrays wordpress multidimensional-array
I've this array set to a WordPress user on my WordPress page:
Array
(
[0] => Array
(
[0] => 1509
[1] => 1597
)
)
To receive this array I'm doing this:
$get_ids = get_user_meta( 3, 'additional_ids', false );
So good, so far! Now I've a little problem because for example I need to remove the value 1509 from the user_meta
. So I thirst tried to find out the key by the value which works good for the moment:
$key = array_search( (int) $value, $get_ids[0], true );
So I've found out now that the key is [0]
. But how can I delete this now a smart way from the user meta and save it that my meta data array looks like this after saving it:
Array
(
[0] => Array
(
[0] => 1597
)
)
This is what I've tried:
//Unset element to delete from the array
unset( $get_ids[0][ $key ] );
//Save it again in the database
update_user_meta( 3, 'additional_ids', $get_ids, false );
But when I do this the array is totally messed up and not longer readable.
php arrays wordpress multidimensional-array
php arrays wordpress multidimensional-array
edited Nov 26 '18 at 6:51
Mr. Jo
asked Nov 26 '18 at 6:40
Mr. JoMr. Jo
675115
675115
Means, there are chances of multiple arrays and you dont want to specify$get_ids[0]
right?
– Shashidhara
Nov 26 '18 at 6:49
There is just one first array [0] thats because I'm working with 0 here. And I want to remove a child from this parent array in my meta_data field I named in the question. And I don't care the way it should just work. If it's possible to do it without a bug function it would be better but I needs to work for the moment.
– Mr. Jo
Nov 26 '18 at 6:53
Usearray_pop($get_ids[0]);
. Note: it always removes first element.
– Shashidhara
Nov 26 '18 at 6:58
add a comment |
Means, there are chances of multiple arrays and you dont want to specify$get_ids[0]
right?
– Shashidhara
Nov 26 '18 at 6:49
There is just one first array [0] thats because I'm working with 0 here. And I want to remove a child from this parent array in my meta_data field I named in the question. And I don't care the way it should just work. If it's possible to do it without a bug function it would be better but I needs to work for the moment.
– Mr. Jo
Nov 26 '18 at 6:53
Usearray_pop($get_ids[0]);
. Note: it always removes first element.
– Shashidhara
Nov 26 '18 at 6:58
Means, there are chances of multiple arrays and you dont want to specify
$get_ids[0]
right?– Shashidhara
Nov 26 '18 at 6:49
Means, there are chances of multiple arrays and you dont want to specify
$get_ids[0]
right?– Shashidhara
Nov 26 '18 at 6:49
There is just one first array [0] thats because I'm working with 0 here. And I want to remove a child from this parent array in my meta_data field I named in the question. And I don't care the way it should just work. If it's possible to do it without a bug function it would be better but I needs to work for the moment.
– Mr. Jo
Nov 26 '18 at 6:53
There is just one first array [0] thats because I'm working with 0 here. And I want to remove a child from this parent array in my meta_data field I named in the question. And I don't care the way it should just work. If it's possible to do it without a bug function it would be better but I needs to work for the moment.
– Mr. Jo
Nov 26 '18 at 6:53
Use
array_pop($get_ids[0]);
. Note: it always removes first element.– Shashidhara
Nov 26 '18 at 6:58
Use
array_pop($get_ids[0]);
. Note: it always removes first element.– Shashidhara
Nov 26 '18 at 6:58
add a comment |
2 Answers
2
active
oldest
votes
The first thing we need to address is how you added the meta to your user. If you use add_user_meta
, you can add multiple meta values under the same meta key. Like this:
//add_user_meta( $user_id, $meta_key, $meta_value, $unique );
add_user_meta(3, 'additional_ids', 1597, false);
add_user_meta(3, 'additional_ids', 1509, false);
Doing this will add both 1509 and 1597 to the user meta additional_ids
.
If you've added the meta fields this way, it will allow you to get all values by using get_user_meta
like this:
$additional_ids = get_user_meta(3, 'additional_ids', false);
Which will return an array like this:
Array (
[0] => 1597
[1] => 1509
)
You can however delete any value from the array without grabbing the array first by using delete_user_meta();
to remove that specific value.
Like this:
delete_user_meta( 3, 'additional_ids', 1509 );
Which would mean that if you get the additional ids again, it would look like this:
$additional_ids = get_user_meta(3, 'additional_ids', false);
print_r($additional_ids);
//prints out:
Array (
[0] => 1597
)
The third argument inside that function will ensure that only metadata with that specific value will be removed.
Doing it this way removes the need to try and find the key associated to the value you want to delete, and will also ensure that you don't accidentally mess with any of the other values that may or may not be in that array.
Tried exact the same thing but the array is still the same after doing the delete function.
– Mr. Jo
Nov 26 '18 at 7:10
Oh I see, the problem is that you have saved all your ids into an array, and added it to a single instance of user meta, instead of saving to multiple instances. Not sure if you are aware of this, but you can keep adding meta with the same meta_key, and when youget_user_meta
you receive back an array of all of those saved values. Once it runs that way, you will be able to make use of thedelete_user_meta
appropriately. - hope it helps :) @Mr.Jo
– Frits
Nov 26 '18 at 7:15
1
@Mr.Jo - ah, that's because I made a mistake with theadd_user_meta()
third argument, it should be false, not true. I've edited my answer to show the correct statement :)
– Frits
Nov 26 '18 at 12:20
1
I'm currently implementing these changes you've made. I'll let you know if it works today and tick your answer! Thank you so much for your time you spent on this.
– Mr. Jo
Nov 26 '18 at 14:11
1
@Mr.Jo I’m super happy to have helped :)
– Frits
Nov 26 '18 at 18:09
|
show 6 more comments
after you do the unset() you will just need to update $get_ids[0] with array_values() to rebase the array again
//Unset element to delete from the array
unset( $get_ids[0][ $key ] );
// rebase the array
$get_ids[0] = array_values( $get_ids[0] );
//Save it again in the database
update_user_meta( 3, 'additional_ids', $get_ids, false );
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53475892%2fdelete-value-by-key-in-user-meta-array-in-wordpress%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The first thing we need to address is how you added the meta to your user. If you use add_user_meta
, you can add multiple meta values under the same meta key. Like this:
//add_user_meta( $user_id, $meta_key, $meta_value, $unique );
add_user_meta(3, 'additional_ids', 1597, false);
add_user_meta(3, 'additional_ids', 1509, false);
Doing this will add both 1509 and 1597 to the user meta additional_ids
.
If you've added the meta fields this way, it will allow you to get all values by using get_user_meta
like this:
$additional_ids = get_user_meta(3, 'additional_ids', false);
Which will return an array like this:
Array (
[0] => 1597
[1] => 1509
)
You can however delete any value from the array without grabbing the array first by using delete_user_meta();
to remove that specific value.
Like this:
delete_user_meta( 3, 'additional_ids', 1509 );
Which would mean that if you get the additional ids again, it would look like this:
$additional_ids = get_user_meta(3, 'additional_ids', false);
print_r($additional_ids);
//prints out:
Array (
[0] => 1597
)
The third argument inside that function will ensure that only metadata with that specific value will be removed.
Doing it this way removes the need to try and find the key associated to the value you want to delete, and will also ensure that you don't accidentally mess with any of the other values that may or may not be in that array.
Tried exact the same thing but the array is still the same after doing the delete function.
– Mr. Jo
Nov 26 '18 at 7:10
Oh I see, the problem is that you have saved all your ids into an array, and added it to a single instance of user meta, instead of saving to multiple instances. Not sure if you are aware of this, but you can keep adding meta with the same meta_key, and when youget_user_meta
you receive back an array of all of those saved values. Once it runs that way, you will be able to make use of thedelete_user_meta
appropriately. - hope it helps :) @Mr.Jo
– Frits
Nov 26 '18 at 7:15
1
@Mr.Jo - ah, that's because I made a mistake with theadd_user_meta()
third argument, it should be false, not true. I've edited my answer to show the correct statement :)
– Frits
Nov 26 '18 at 12:20
1
I'm currently implementing these changes you've made. I'll let you know if it works today and tick your answer! Thank you so much for your time you spent on this.
– Mr. Jo
Nov 26 '18 at 14:11
1
@Mr.Jo I’m super happy to have helped :)
– Frits
Nov 26 '18 at 18:09
|
show 6 more comments
The first thing we need to address is how you added the meta to your user. If you use add_user_meta
, you can add multiple meta values under the same meta key. Like this:
//add_user_meta( $user_id, $meta_key, $meta_value, $unique );
add_user_meta(3, 'additional_ids', 1597, false);
add_user_meta(3, 'additional_ids', 1509, false);
Doing this will add both 1509 and 1597 to the user meta additional_ids
.
If you've added the meta fields this way, it will allow you to get all values by using get_user_meta
like this:
$additional_ids = get_user_meta(3, 'additional_ids', false);
Which will return an array like this:
Array (
[0] => 1597
[1] => 1509
)
You can however delete any value from the array without grabbing the array first by using delete_user_meta();
to remove that specific value.
Like this:
delete_user_meta( 3, 'additional_ids', 1509 );
Which would mean that if you get the additional ids again, it would look like this:
$additional_ids = get_user_meta(3, 'additional_ids', false);
print_r($additional_ids);
//prints out:
Array (
[0] => 1597
)
The third argument inside that function will ensure that only metadata with that specific value will be removed.
Doing it this way removes the need to try and find the key associated to the value you want to delete, and will also ensure that you don't accidentally mess with any of the other values that may or may not be in that array.
Tried exact the same thing but the array is still the same after doing the delete function.
– Mr. Jo
Nov 26 '18 at 7:10
Oh I see, the problem is that you have saved all your ids into an array, and added it to a single instance of user meta, instead of saving to multiple instances. Not sure if you are aware of this, but you can keep adding meta with the same meta_key, and when youget_user_meta
you receive back an array of all of those saved values. Once it runs that way, you will be able to make use of thedelete_user_meta
appropriately. - hope it helps :) @Mr.Jo
– Frits
Nov 26 '18 at 7:15
1
@Mr.Jo - ah, that's because I made a mistake with theadd_user_meta()
third argument, it should be false, not true. I've edited my answer to show the correct statement :)
– Frits
Nov 26 '18 at 12:20
1
I'm currently implementing these changes you've made. I'll let you know if it works today and tick your answer! Thank you so much for your time you spent on this.
– Mr. Jo
Nov 26 '18 at 14:11
1
@Mr.Jo I’m super happy to have helped :)
– Frits
Nov 26 '18 at 18:09
|
show 6 more comments
The first thing we need to address is how you added the meta to your user. If you use add_user_meta
, you can add multiple meta values under the same meta key. Like this:
//add_user_meta( $user_id, $meta_key, $meta_value, $unique );
add_user_meta(3, 'additional_ids', 1597, false);
add_user_meta(3, 'additional_ids', 1509, false);
Doing this will add both 1509 and 1597 to the user meta additional_ids
.
If you've added the meta fields this way, it will allow you to get all values by using get_user_meta
like this:
$additional_ids = get_user_meta(3, 'additional_ids', false);
Which will return an array like this:
Array (
[0] => 1597
[1] => 1509
)
You can however delete any value from the array without grabbing the array first by using delete_user_meta();
to remove that specific value.
Like this:
delete_user_meta( 3, 'additional_ids', 1509 );
Which would mean that if you get the additional ids again, it would look like this:
$additional_ids = get_user_meta(3, 'additional_ids', false);
print_r($additional_ids);
//prints out:
Array (
[0] => 1597
)
The third argument inside that function will ensure that only metadata with that specific value will be removed.
Doing it this way removes the need to try and find the key associated to the value you want to delete, and will also ensure that you don't accidentally mess with any of the other values that may or may not be in that array.
The first thing we need to address is how you added the meta to your user. If you use add_user_meta
, you can add multiple meta values under the same meta key. Like this:
//add_user_meta( $user_id, $meta_key, $meta_value, $unique );
add_user_meta(3, 'additional_ids', 1597, false);
add_user_meta(3, 'additional_ids', 1509, false);
Doing this will add both 1509 and 1597 to the user meta additional_ids
.
If you've added the meta fields this way, it will allow you to get all values by using get_user_meta
like this:
$additional_ids = get_user_meta(3, 'additional_ids', false);
Which will return an array like this:
Array (
[0] => 1597
[1] => 1509
)
You can however delete any value from the array without grabbing the array first by using delete_user_meta();
to remove that specific value.
Like this:
delete_user_meta( 3, 'additional_ids', 1509 );
Which would mean that if you get the additional ids again, it would look like this:
$additional_ids = get_user_meta(3, 'additional_ids', false);
print_r($additional_ids);
//prints out:
Array (
[0] => 1597
)
The third argument inside that function will ensure that only metadata with that specific value will be removed.
Doing it this way removes the need to try and find the key associated to the value you want to delete, and will also ensure that you don't accidentally mess with any of the other values that may or may not be in that array.
edited Nov 26 '18 at 12:18
answered Nov 26 '18 at 6:55
FritsFrits
4,312102337
4,312102337
Tried exact the same thing but the array is still the same after doing the delete function.
– Mr. Jo
Nov 26 '18 at 7:10
Oh I see, the problem is that you have saved all your ids into an array, and added it to a single instance of user meta, instead of saving to multiple instances. Not sure if you are aware of this, but you can keep adding meta with the same meta_key, and when youget_user_meta
you receive back an array of all of those saved values. Once it runs that way, you will be able to make use of thedelete_user_meta
appropriately. - hope it helps :) @Mr.Jo
– Frits
Nov 26 '18 at 7:15
1
@Mr.Jo - ah, that's because I made a mistake with theadd_user_meta()
third argument, it should be false, not true. I've edited my answer to show the correct statement :)
– Frits
Nov 26 '18 at 12:20
1
I'm currently implementing these changes you've made. I'll let you know if it works today and tick your answer! Thank you so much for your time you spent on this.
– Mr. Jo
Nov 26 '18 at 14:11
1
@Mr.Jo I’m super happy to have helped :)
– Frits
Nov 26 '18 at 18:09
|
show 6 more comments
Tried exact the same thing but the array is still the same after doing the delete function.
– Mr. Jo
Nov 26 '18 at 7:10
Oh I see, the problem is that you have saved all your ids into an array, and added it to a single instance of user meta, instead of saving to multiple instances. Not sure if you are aware of this, but you can keep adding meta with the same meta_key, and when youget_user_meta
you receive back an array of all of those saved values. Once it runs that way, you will be able to make use of thedelete_user_meta
appropriately. - hope it helps :) @Mr.Jo
– Frits
Nov 26 '18 at 7:15
1
@Mr.Jo - ah, that's because I made a mistake with theadd_user_meta()
third argument, it should be false, not true. I've edited my answer to show the correct statement :)
– Frits
Nov 26 '18 at 12:20
1
I'm currently implementing these changes you've made. I'll let you know if it works today and tick your answer! Thank you so much for your time you spent on this.
– Mr. Jo
Nov 26 '18 at 14:11
1
@Mr.Jo I’m super happy to have helped :)
– Frits
Nov 26 '18 at 18:09
Tried exact the same thing but the array is still the same after doing the delete function.
– Mr. Jo
Nov 26 '18 at 7:10
Tried exact the same thing but the array is still the same after doing the delete function.
– Mr. Jo
Nov 26 '18 at 7:10
Oh I see, the problem is that you have saved all your ids into an array, and added it to a single instance of user meta, instead of saving to multiple instances. Not sure if you are aware of this, but you can keep adding meta with the same meta_key, and when you
get_user_meta
you receive back an array of all of those saved values. Once it runs that way, you will be able to make use of the delete_user_meta
appropriately. - hope it helps :) @Mr.Jo– Frits
Nov 26 '18 at 7:15
Oh I see, the problem is that you have saved all your ids into an array, and added it to a single instance of user meta, instead of saving to multiple instances. Not sure if you are aware of this, but you can keep adding meta with the same meta_key, and when you
get_user_meta
you receive back an array of all of those saved values. Once it runs that way, you will be able to make use of the delete_user_meta
appropriately. - hope it helps :) @Mr.Jo– Frits
Nov 26 '18 at 7:15
1
1
@Mr.Jo - ah, that's because I made a mistake with the
add_user_meta()
third argument, it should be false, not true. I've edited my answer to show the correct statement :)– Frits
Nov 26 '18 at 12:20
@Mr.Jo - ah, that's because I made a mistake with the
add_user_meta()
third argument, it should be false, not true. I've edited my answer to show the correct statement :)– Frits
Nov 26 '18 at 12:20
1
1
I'm currently implementing these changes you've made. I'll let you know if it works today and tick your answer! Thank you so much for your time you spent on this.
– Mr. Jo
Nov 26 '18 at 14:11
I'm currently implementing these changes you've made. I'll let you know if it works today and tick your answer! Thank you so much for your time you spent on this.
– Mr. Jo
Nov 26 '18 at 14:11
1
1
@Mr.Jo I’m super happy to have helped :)
– Frits
Nov 26 '18 at 18:09
@Mr.Jo I’m super happy to have helped :)
– Frits
Nov 26 '18 at 18:09
|
show 6 more comments
after you do the unset() you will just need to update $get_ids[0] with array_values() to rebase the array again
//Unset element to delete from the array
unset( $get_ids[0][ $key ] );
// rebase the array
$get_ids[0] = array_values( $get_ids[0] );
//Save it again in the database
update_user_meta( 3, 'additional_ids', $get_ids, false );
add a comment |
after you do the unset() you will just need to update $get_ids[0] with array_values() to rebase the array again
//Unset element to delete from the array
unset( $get_ids[0][ $key ] );
// rebase the array
$get_ids[0] = array_values( $get_ids[0] );
//Save it again in the database
update_user_meta( 3, 'additional_ids', $get_ids, false );
add a comment |
after you do the unset() you will just need to update $get_ids[0] with array_values() to rebase the array again
//Unset element to delete from the array
unset( $get_ids[0][ $key ] );
// rebase the array
$get_ids[0] = array_values( $get_ids[0] );
//Save it again in the database
update_user_meta( 3, 'additional_ids', $get_ids, false );
after you do the unset() you will just need to update $get_ids[0] with array_values() to rebase the array again
//Unset element to delete from the array
unset( $get_ids[0][ $key ] );
// rebase the array
$get_ids[0] = array_values( $get_ids[0] );
//Save it again in the database
update_user_meta( 3, 'additional_ids', $get_ids, false );
answered Nov 26 '18 at 8:21
Ash0urAsh0ur
569128
569128
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53475892%2fdelete-value-by-key-in-user-meta-array-in-wordpress%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Means, there are chances of multiple arrays and you dont want to specify
$get_ids[0]
right?– Shashidhara
Nov 26 '18 at 6:49
There is just one first array [0] thats because I'm working with 0 here. And I want to remove a child from this parent array in my meta_data field I named in the question. And I don't care the way it should just work. If it's possible to do it without a bug function it would be better but I needs to work for the moment.
– Mr. Jo
Nov 26 '18 at 6:53
Use
array_pop($get_ids[0]);
. Note: it always removes first element.– Shashidhara
Nov 26 '18 at 6:58