Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
At the moment, I'm working on a small script.
I'm new at PHP, I've got a problem
I have a field in database and the field content is like this
"1","2","3"
When i put these numbers in array
like this
$users=array("1","2","3");
, my code will work , but when i put these codes in a variable and put variable inside the array like this
$users=array($amanj);
it wont.
Please Help me if possible.
Thanks very much.
It sounds like you need to redesign your database because having "1","2","3" is not a good idea if you really need 3 separate values.
But to answer your question, if you need to convert the string "1","2","3" to an array, you can do:
$users = explode(',', $amanj);
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
Below are the results of my query. I would just like to return the refundable_amount value. Which for this query $4.04
a:1:{i:0;a:19:{s:8:"label_id";i:3324543;s:8:"tracking";s:22:"9400136205309684548265";s:17:**"refundable_amount";d:4.04**;s:7:"created";i:1614781854687;s:10:"carrier_id";s:4:"usps";s:12:"service_name";s:23:"USPS - First Class Mail";s:6:"status";s:9:"PURCHASED";s:22:"commercial_invoice_url";N;s:12:"package_name";s:11:"Single Kcup";s:9:"is_letter";b:0;s:13:"product_names";a:1:{i:0;s:28:"Multiple Aware";}s:11:"product_ids";a:1:{i:0;i:1212;}s:15:"receipt_item_id";i:72845982;s:12:"created_date";i:1614781859000;s:11:"expiry_date";i:1630333858000;s:15:"main_receipt_id";i:54663164;s:4:"rate";d:4.04;s:8:"currency";s:3:"USD";s:12:"label_cached";i:1614781863000;}}
Thank you in advance for any help.
You have typo, in near the "Multiple Aware" output, it should be 14, if you correct it like below,
Then you can use php unserialize function
$text = unserialize ('a:1:{i:0;a:19:{s:8:"label_id";i:3324543;s:8:"tracking";s:22:"9400136205309684548265";s:17:"refundable_amount";d:4.04;s:7:"created";i:1614781854687;s:10:"carrier_id";s:4:"usps";s:12:"service_name";s:23:"USPS - First Class Mail";s:6:"status";s:9:"PURCHASED";s:22:"commercial_invoice_url";N;s:12:"package_name";s:11:"Single Kcup";s:9:"is_letter";b:0;s:13:"product_names";a:1:{i:0;s:14:"Multiple Aware";}s:11:"product_ids";a:1:{i:0;i:1212;}s:15:"receipt_item_id";i:72845982;s:12:"created_date";i:1614781859000;s:11:"expiry_date";i:1630333858000;s:15:"main_receipt_id";i:54663164;s:4:"rate";d:4.04;s:8:"currency";s:3:"USD";s:12:"label_cached";i:1614781863000;}}');
you can get the value as below,
echo $text[0]['rate'];
will output
4.04
For more information about this function you can visit
https://www.php.net/manual/en/function.unserialize.php
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
a challenge like this $_GET['2020'] snippet boring me a long time, i want to know how this work, but do not know which keywords to search, maybe how the parameter works?
$_GET reads querystring parameters from the URL. So if someone goes to your PHP script with a URL like http://servername/scriptname.php?2020=ABC then when the PHP script runs, the variable $_GET['2020'] will contain the value ABC.
More info is available in the documentation: https://www.php.net/manual/en/reserved.variables.get.php
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have a school website, I have uploaded the students examination result to the database but now I want to make a search bar by which can the student search their result by typing their roll number.
please someone give me the code. please
#wajahat-aftab - you can always find a great tutorial to do this. Here are few of the links
https://www.youtube.com/watch?v=N_S7_wg87GU
http://html.net/tutorials/php/
http://www.htmlgoodies.com/beyond/php/article.php/3472391
Basically you need to get the data, manipulate it and send it to the HTML page. Once you get the data in HTML you can present it any kind of look-n-feel as per your needs.
You can not expect exact answers for such questions - so I suggest you to be more specific with QUESTION and make sure that you also share the source code that you tried so far.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a php array which is created from data in an sql database.
All I want to do is recreate that identical array on another site.
I can print_r it no worries. But how would I output the structure of the array so that I can go as follows on the new site.
$newvar = array(.....);
I'm sure it's a very simply question, But I can't find an answer.
serialize Try this function. I think this is what you need
you can use json_encode to send your array and keep the structure of your array.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
The problem is that I must catch situation when some variable (and I don't know it's name, that is I don't know where this value first arises) matches some record in database. The way I think it could be done is to run after each statement an external code against array of local and remote variables. In that external code would be a simple foreach loop and db query, the script would then output line number where given situation happened.
Is this possible with xdebug ?
There is a function for that, http://php.net/manual/en/function.register-tick-function.php more documentation on ticks is http://www.php.net/manual/en/control-structures.declare.php here.