Recreating a dynamic php array [closed] - 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 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.

Related

what are the other ways to fetch data from mysql than Mysqli_fetch_array(); [closed]

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 2 years ago.
Improve this question
I have been working on a project and I wanted to try something new to fetch data from MySQL. I am looking to get data to the project other than using
mysql_fetch_assoc()
If there can be any other way please let me know.
You can use mysqli_fetch_all() which fetches all result rows and returns the result-set as an associative array, a numeric array, or both.
mysqli_fetch_all(result, resulttype)

Python equivalent of the PHP stdClass [closed]

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 3 years ago.
Improve this question
Coming from PHP, I love the pythonic syntax.
Is there a Python equivalent of the PHP stdClass?
Edit:
I want to point out I'm looking for a specific data type in Python to store data like the stdClass in PHP. So not in a dict, list, array, .. but in an object. Does there exist a specific data type in Python to store only data that behaves like an object?
You can do:
class StdClass:
pass

How to insert POST data [closed]

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 do not know how to insert POST data to mongodb collection. I try to do it like this:
$collection ->insert($_POST);
But in this case I get An Internal Server Error. What is the best and most concise way to do it?
Better way to make an array of all post data and pass it to insert like
<?php
$post = array("username" =>$_POST['username'], "password" => $_POST['password']);
$collection->insert($post);
?>

When we pass an array as an argument to a function, what actually gets passed? [closed]

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
When we pass an array as an argument to a function, what actually gets passed?
Someone told me that it is "Base address of the array"? but I am not sure about it. How this array is processed then?
this is the answer: Are arrays in PHP passed by value or by reference?

My small code is not working [closed]

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);

Categories