2210 posts
  • Has referred 200+ members
  • Has sold $500,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+13 more
mpc 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
  • Has been part of the Envato Community for over 4 years
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
iamthwee says

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

2210 posts
  • Has referred 200+ members
  • Has sold $500,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+13 more
mpc 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
  • Has been part of the Envato Community for over 4 years
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
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.’ ?

2210 posts
  • Has referred 200+ members
  • Has sold $500,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+13 more
mpc 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
  • Has been part of the Envato Community for over 4 years
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
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
  • Has been part of the Envato Community for over 3 years
  • Has referred 50+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 1+ items on Envato Market
+2 more
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" ?>
774 posts
  • Has referred 1+ members
  • Has sold $1,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Has been part of the Envato Community for over 7 years
+4 more
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 part of the Envato Community for over 1 year
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
366 posts
  • Has been part of the Envato Community for over 2 years
  • Has referred 1+ members
  • Has sold $1,000+ on Envato Market
  • Has collected 10+ items on Envato Market
+2 more
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

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by