0

I am using Drupal 7 and drush 7.4.0. How do I handle array variables with drush?

For example, I have a variable, social_sharing, for which

drush vget social_sharing 

Produces:

facebook: facebook
google_plus: google_plus
linkedin: linkedin
twitter: twitter
pininterest: pininterest

Using a drush command,

  1. How can I get the value of only facebook using drush vget?
  2. How can I delete one specific variable? for example if I want to remove google_plus from the list using drush vdel?
0

Step 1. Get the value of only facebook

drush ev '$v=variable_get("social_sharing"); print $v["facebook"]; print PHP_EOL';

Step 2. Remove google_plus from the list

drush ev '$v=variable_get("social_sharing"); unset($v["google_plus"]); variable_set("social_sharing", $v);'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.