This question already has answers here:
How to use php serialize() and unserialize()
(10 answers)
Closed 5 years ago.
I have this record in data base row :
a:2:
{
i:2;a:2:{s:6:"amount";d:150;s:11:"description";s:53:"value1";}
i:3;a:2:{s:6:"amount";d:1800;s:11:"description";s:53:"value 2";}
}
Is it Json or What exactly ?
And how can i extract data from it ?
I want to get each amount and description values
It's serialized data. You can use unserialize() to turn it in to an array.
Related
This question already has answers here:
calculate math expression from a string using eval
(10 answers)
Closed 4 years ago.
If i've a string like this
((((((4,50*0,86)*52500*1,0016)+3800)/52500)*2,2046)*1,05)
how can i do the operation for obtaning the total result?
Thank You
Maybe your question is a possible duplicate from calculate-math-expression-from-a-string-using-eval
However
if you need to store this in a variable you can do
$string='((((((4,50*0,86)*52500*1,0016)+3800)/52500)*2,2046)*1,05)';
$response=eval('return '.str_replace(',','.',$string.';'));
print($response);
the output is:
9.14027512736
This question already has answers here:
How to loop through PHP object with dynamic keys [duplicate]
(16 answers)
php - deep search array of arrays and return only matching elements
(5 answers)
Closed 5 years ago.
I find this quite hard to explain as you can see in the title but let's say this is how my object looks like,
{
"success":true,
"objects":[
{
"name":"Stick",
"value":"wood",
"size":"large"
}...
]
}
Now I'm trying to get all the data where the objects name is Stick, so basically if it's "name" is stick it should return, name, value and size.
This question already has an answer here:
How to find a document by embedded item in MongoDB PHP
(1 answer)
Closed 5 years ago.
I have an ID, and I want to get all documents that has this ID in array.
How can i get all documents that:
my_ID in {recipients.ids}
I think this is something like the "opposite" to $in.
Thanks.
If I understood correctly, this should do it:
db.your_collection.find({'ids.recipients': 'the_id_you_look_for'})
This question already has an answer here:
How to extract and access data from JSON with PHP?
(1 answer)
Closed 6 years ago.
I have multidimensional array string stored in PHP variable and I want to extract the keys and its values. Below is the given string which need to be split.
[{"cutoffTime":"1","refundInPercentage":"50"},
{"cutoffTime":"3","refundInPercentage":"70"},
{"cutoffTime":"6","refundInPercentage":"90"}
]
How can I extract this?
Try this to have your work done
json_decode($string)
This question already has answers here:
How to access and manipulate multi-dimensional array by key names / path?
(10 answers)
Convert delimited string into array key path and assign value
(5 answers)
Closed 7 years ago.
How do I turn this:
$keys=array(1,8,27);
Into this?
$array=array();
$array[1][8][27]='Hooray!';
I have an array that I need as the keys of a multidimensional array.
In the example:
I am using 1, 8 and 27.
I think this would work:
$array[$keys[0]][$keys[1]][$keys[2]] = "Hooray!";
Can't even begin to imagine how to go about making it dynamic though.