[Solved] How to get Joomla users data into a json array [closed]

You are overwriting the $id variable and then you are not using it… It seems there’s a mess in there with the $title, $name and $id variables. Try this: <?php $sql = “SELECT * FROM `jos_users` LIMIT 0, 30 “; $response = array(); $posts = array(); $result=mysql_query($sql); while($row=mysql_fetch_array($result)) { $id=$row[‘id’]; //change here $name=$row[‘name’]; //change here … Read more

[Solved] How to Merge CSV Files in PHP, Line by Line

Try this php code (gets the lines with file()).: <?php $csv1 = file(‘csv1.csv’, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $csv2 = file(‘csv2.csv’, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $csv3 = file(‘csv3.csv’, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $lines = max(count($csv1), count($csv2), count($csv3)); $finalcsv = array(); for($i=0; $i<$lines; $i++) { if(isset($csv1[$i])) $finalcsv[] = $csv1[$i]; if(isset($csv2[$i])) $finalcsv[] = $csv2[$i]; if(isset($csv3[$i])) $finalcsv[] = $csv3[$i]; } file_put_contents(‘final_data.csv’, implode(PHP_EOL, … Read more

[Solved] Passing PHP-variable to Javascript doesn’t work via PHP-function (not about global variables) [duplicate]

Don’t use global variables, it’s a poor practice to get in the habit of. You should pass the value into the function as an argument: function test23( $var_external ){ // do stuff to modify it return $var_external; } Then print the result: <?php print test23($var_external); ?> It’s hard to give better advice because I don’t … Read more

[Solved] group key based on value array php [closed]

Is this what you are looking for? $data = array(); $data[“user-insert-resp.php”] = “123”; $data[“login.php”] = “123”; $data[“project-view.php”] = “13”; $flipped_data = array(); foreach($data as $key=>$value){ if(!isset($flipped_data[$value])){ $flipped_data[$value] = array(); } $flipped_data[$value][] = $key; } Result: Array ( [123] => Array ( [0] => user-insert-resp.php [1] => login.php ) [13] => Array ( [0] => project-view.php … Read more

[Solved] stop people stealing files from site [closed]

You can use an authentication system, and do not present the public url to the downloader. For example, you create a table like: file_name | file_path | file_code ——————————————————- My picture | /var/docs/img.jpg | kljsldjalksdqhq1218 And after the user is logged in (and meets the criteria you defined) you present him with the download link: … Read more

[Solved] Access data in an array

Its hard to tell because you didnt post the code you are using but i suspect you are confusing the structure type. What you posted is actually an object – an instance of stdClass and the items that look like array elements are in fact properties on that object. So you need to use the … Read more

[Solved] php numbers like (10M, ..)

You could whip up your own function, because there isn’t an builtin function for this. To give you an idea: function strtonum($string) { $units = [ ‘M’ => ‘1000000’, ‘K’ => ‘1000’, ]; $unit = substr($string, -1); if (!array_key_exists($unit, $units)) { return ‘ERROR!’; } return (int) $string * $units[$unit]; } Demo: http://codepad.viper-7.com/2rxbP8 Or the other … Read more

[Solved] Number formatting

Just change your if condition and remove 1x zero, so from this: if ($number < 10000) { return pm_number_format($number); } to this: if ($number < 1000) { return pm_number_format($number); } Input: 1 12 123 1234 12345 123456 1234567 12345678 123456789 Output: 1 12 123 1.2K //<–See output as you wanted 12.3K 123.5K 1.2M 12.3M 123.5M … Read more