Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
If I have an array with identifiers like this "name" => "Manoel", "age" => 45 then how can I turn them into individual variables without having to know each identifier in the array? is it possible?
Can I do that inside a class to create new properties?
Thanks.
Try this:
<?php
$Wales = 'Swansea \n';
print $Wales;
$capitalcities['England'] = 'London';
$capitalcities['Scotland'] = 'Edinburgh';
$capitalcities['Wales'] = 'Cardiff';
extract($capitalcities);
print $Wales;
?>
The result you should see in your browser is:
Swansea
Cardiff
And yes, if you do this inside an object you may have those variables as properties in execution time.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have field in my table with data: DE;RO;US;
Question is how extract data in array as:
$array = array('DE', 'RO', 'US');
use explode function.
Like this :
$string = 'DE;RO;US;';
$arr = explode(';',$string);
You can use the function explode() here.
$array = explode(';', $data);
The variable data is the result of you database query.
http://us1.php.net/manual/en/function.explode.php
BTW: Your way to save things in the database is not good. Have a look at database normalization.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
How does one display the USD exchange rate from https://bitpay.com/api/rates using PHP on a web page?
ie, that in the first line:
{"code":"USD","name":"US Dollar","rate":325.8}
you need json_decode() from php
it will convert the json data to a php object
but as suggested by Marc B
write some code
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Why when it displays does it say Resource id #2?
All I am doing is fetching a simple number (0) out of a .txt file:
$num = fopen('qnum/qnum.txt', 'r');
echo $num;
You are not actually reading the file. You are only opening it and acquiring a reference to the file. You have to add more code (e.g. something along the lines of the answers to this question) to read the contents of the file.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I suck at regexp but i'd like to just do a simple filter where / is replaced with 1, " is replaced with 2 and < is replaced with 3.
I'd appreciate an example where the syntax would be straight forward, i'd like to run this filter through the input of a get variable provided by the user. A syntax like:
replace(/,1)
replace(",2)
replace(<,3)
.
Thanks.
I really don't see the need for regex here.. You can just use str_replace
E.g.
str_replace('/', '1', $_GET['var']);
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions must demonstrate a minimal understanding of the problem being solved. Tell us what you've tried to do, why it didn't work, and how it should work. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am new to json and I am facing a problem in sending more than one 2D array to python script from php script for calculation. Can anyone help me with that?
Build an array-of-arrays and encode that?
$meta_arr = array(
'array1' => $array_number_one,
'array2' => $array_number_two
);
echo json_encode($meta_arr);