Posts Tagged with php 5

Displaying 1-6 of 6 results.
Resolved: Composer Ubuntu installation and errors
posted by admin on January 18, 2017
I am trying to install composer by that way and get some errors.
Instalation
Step 1: Ensure the Curl dependency is installed.

sudo apt-get -y install curl


Step 2: Download the Composer installer and pass it to php.

sudo curl -sS https://getcomposer.org/installer | php

My error in this step:

The program 'php' can be found in the following packages:
* php7.0-cli
* hhvm
Try: sudo apt install <selected package>
curl: (23) Failed writing body (0 != 16133)
Read more
Resolved: PHP echo link content in page
posted by admin on October 26, 2016
I am working on website and in locale and want to show in my page part of code from live server.
like

echo PHP_LINK_READER_FUNCTION("SOME_URL");
Read more
Resolved: Parse error: syntax error, unexpected '[', expecting ')'
posted by admin on June 3, 2016
I have error in oscarotero Embed APP.Read more
Resolved: error :should not be called statically, assuming $this from incompatible context. only on my machine
posted by admin on June 3, 2016
My team members wrote the model function calls in the controller statically such as:

$data = ModelName::functionName($param);

while it should be called dynamically such as:

$model = new Model();
$data = $model->functionName($param);

mostly all the calls are made statically. the code is working on the server and on their local machines except for mine. And the static calls are too many to fix without rewriting huge code base.

I always update my project via composer. My php version is 5.4.

anyone might know what this is about?Read more
Resolved: Remove the last character(comma) from string
posted by admin on May 6, 2016
I have a string like

a,b,c,d,e,


I would like to remove last ',' and get the remaining string back

OUTPUT: a,b,c,d,e
Read more
Wiki: PHP 5 Sorting Arrayswiki
posted by admin on April 16, 2016
The elements in an array can be sorted in alphabetical or numerical order, descending or ascending.

PHP - Sort Functions For Arrays

In this chapter, we will go through the following PHP array sort functions:
  • sort() - sort arrays in ascending order
  • rsort() - sort arrays in descending order
  • asort() - sort associative arrays in ascending order, according to the value
  • ksort() - sort associative arrays in ascending order, according to the key
  • arsort() - sort associative arrays in descending order, according to the value
  • krsort() - sort associative arrays in descending order, according to the key


Sort Array in Ascending Order - sort()
The following example sorts the elements of the $cars array in ascending alphabetical order:

<?php
$cars = array("Volvo", "BMW", "Toyota");
sort($cars);
?>


The following example sorts the elements of the $numbers array in ascending numerical order:

<?php
$numbers = array(4, 6, 2, 22, 11);
sort($numbers);
?>


Sort Array in Descending Order - rsort()
The following example sorts the elements of the $cars array in descending alphabetical order:

<?php
$cars = array("Volvo", "BMW", "Toyota");
rsort($cars);
?>


The following example sorts the elements of the $numbers array in descending numerical order:

<?php
$numbers = array(4, 6, 2, 22, 11);
rsort($numbers);
?>


Sort Array (Ascending Order), According to Value - asort()
The following example sorts an associative array in ascending order, according to the value:

<?php
$age = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");
asort($age);
?>


Sort Array (Ascending Order), According to Key - ksort()
The following example sorts an associative array in ascending order, according to the key:

<?php
$age = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");
ksort($age);
?>


Sort Array (Descending Order), According to Value - arsort()
The following example sorts an associative array in descending order, according to
arsort($age);
?>
[/php]

Sort Array (Descending Order), According to Key - krsort()
The following example sorts an associative array in descending order, according to the key:

<?php
$age = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");
krsort($age);
?>
Read more