2177 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Exclusive Author
  • Community Moderator
  • Bought between 50 and 99 items
  • Referred between 200 and 499 users
  • Has been a member for 5-6 years
  • Won a Competition
+10 more
mpc Volunteer moderator says

Ok another way to solve my problem i making a reference to the element in an array any way to do that? :)

812 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 4-5 years
iamthwee says

A full complete example would be great, otherwise we can play the 20 questions game all day.

2177 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Exclusive Author
  • Community Moderator
  • Bought between 50 and 99 items
  • Referred between 200 and 499 users
  • Has been a member for 5-6 years
  • Won a Competition
+10 more
mpc Volunteer moderator says

You want me to post 700 lines of code which uses WordPress API and explain it to you? :) I need an answer to one of two questions:

1. How to use a string variable as a path to arrays element?

2. How to make a reference to element inside an array?

I think those questions are strait forward and doesn’t need example at all…

But if you need an example here it is:

//First question

$my_array = array('something' => 'foo');
$my_path = '[something]';

echo $my_array.$my_path; // use the path to echo 'something' element (I KNOW THIS IS WRONG)

Second Question

$my_array = array('something' => 'foo');
$my_element = $my_array['something'];

$my_element = 'new value'; // I want this to be changed inside the $my_array so the $my_element needs to be a reference.
812 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 4-5 years
iamthwee says

You want me to post 700 lines of code which uses WordPress API and explain it to you? :)

No I don’t mean to be rude, but there probably is a language issue which isn’t helping matters.

$my_array = array('something' => 'foo', 'something2' => 'bar');

//You want to change something to 'hello
$my_array['something'] = 'hello';

echo $my_array['something'];

Changing a value in the associative array is simple. Once you know what the key is just change it to your string variable?

Unless you want to loop through the array for the word ‘foo’ and then spit out its associative key pair is ‘something.’ ?

2177 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Exclusive Author
  • Community Moderator
  • Bought between 50 and 99 items
  • Referred between 200 and 499 users
  • Has been a member for 5-6 years
  • Won a Competition
+10 more
mpc Volunteer moderator says

Ok nvm, you are simply thinking I don’t know how to use an array :) but the problem is much deeper. Thanks anyway.

BTW I have solved the issue the other way.

812 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 4-5 years
iamthwee says

Yeah

It’s like you’re trying to find the name of the ‘ACTUAL’ variable name of the associative pair unless I totally misunderstood the example.

mmm, glad you solved it anyway.

32 posts
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 3-4 years
  • Referred between 50 and 99 users
  • Sold between 10 000 and 50 000 dollars
  • United States
robocreatif says

I use this in my framework for getting the value: http://pastebin.com/XtYE1JHv
You should be able to modify it for setting the value as well.

<?php $array = array('multi' => array('dimensional' => 'abc')); echo array_search_string('multi[dimensional]', $array); // prints "abc" ?>
773 posts
  • Bought between 50 and 99 items
  • Exclusive Author
  • Grew a moustache for the Envato Movember competition
  • Has been a member for 7-8 years
  • Mexico
  • Referred between 1 and 9 users
  • Sold between 1 000 and 5 000 dollars
GARRO says

gees, my eyes are tired, scrolling down the forums I read the title of this thread and read, “After Party” some how inside the title, lol :)

1 post
  • Has been a member for 0-1 years
coderDJ412 says

You’ve probably found what you were looking for since this was posted but I wanted to post this for people who might have stumbled upon this like I have.

http://stackoverflow.com/questions/9056021/curly-braces-notation-in-php
281 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 2-3 years
  • Referred between 1 and 9 users
  • Sold between 1 000 and 5 000 dollars
Deep_Blue says

If I understood what you want correctly then I think you need ‘variable variables’: http://php.net/manual/en/language.variables.variable.php

by
by
by
by
by
by